|
@@ -7,13 +7,13 @@ import com.energy.manage.common.base.Page;
|
|
|
import com.energy.manage.common.constant.redis.ManagerRedisKeyConstant;
|
|
|
import com.energy.manage.common.enums.DeleteStatusEnum;
|
|
|
import com.energy.manage.common.enums.IdPrefixEnum;
|
|
|
-import com.energy.manage.common.po.units.UnitDictBrandModelPO;
|
|
|
-import com.energy.manage.common.po.units.UnitDictConstantsPO;
|
|
|
+import com.energy.manage.common.po.units.*;
|
|
|
import com.energy.manage.common.util.IdGeneratorUtil;
|
|
|
import com.energy.manage.service.domain.dto.units.*;
|
|
|
import com.energy.manage.service.domain.vo.units.UnitDictBrandModelVo;
|
|
|
import com.energy.manage.service.domain.vo.units.UnitDictConstantsVo;
|
|
|
import com.energy.manage.service.domain.vo.units.UnitDictRoutineListVo;
|
|
|
+import com.energy.manage.service.domain.vo.units.UnitVo;
|
|
|
import com.energy.manage.service.mappers.units.*;
|
|
|
import com.energy.manage.service.service.cache.CacheService;
|
|
|
import com.energy.manage.service.service.dict.DictConstantsService;
|
|
@@ -27,6 +27,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import springfox.documentation.schema.Collections;
|
|
|
import tk.mybatis.mapper.entity.Example;
|
|
|
|
|
|
import java.util.Date;
|
|
@@ -57,13 +59,16 @@ public class UnitServiceImpl implements UnitService {
|
|
|
@Autowired
|
|
|
private UnitGearboxBearingsMapper unitGearboxBearingsMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CacheService cacheService;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<UnitDictRoutineListVo> getUnitDictRoutineList(UnitDictRoutineDto unitDictRoutineDto) {
|
|
|
List<UnitDictConstantsVo> unitDictConstantsVos = unitDictConstantsService.getUnitDictConstantsList(unitDictRoutineDto.getContentsType());
|
|
|
UnitDictRoutineListVo vo = null;
|
|
|
List<UnitDictRoutineListVo> listVos = Lists.newArrayList();
|
|
|
- for(UnitDictConstantsVo dictConstantsVo : unitDictConstantsVos){
|
|
|
+ for (UnitDictConstantsVo dictConstantsVo : unitDictConstantsVos) {
|
|
|
vo = new UnitDictRoutineListVo();
|
|
|
vo.setKeyId(dictConstantsVo.getContentsValue());
|
|
|
vo.setValueName(dictConstantsVo.getContentsName());
|
|
@@ -82,9 +87,189 @@ public class UnitServiceImpl implements UnitService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean modificationUnit(UnitDto unitDto) {
|
|
|
|
|
|
+ boolean flg = true;
|
|
|
+ // 处理主轴
|
|
|
+ outBearings:
|
|
|
+ if (unitDto.getUnitBearingsDto() != null) {
|
|
|
+ UnitBearingsPO unitBearingsPO = new UnitBearingsPO();
|
|
|
+ BeanUtil.copyProperties(unitDto.getUnitBearingsDto(), unitBearingsPO);
|
|
|
+
|
|
|
+ //更新
|
|
|
+ if (unitBearingsPO.getId() != null && unitBearingsPO.getId() > 0) {
|
|
|
+ Example queryExample = new Example(UnitBearingsPO.class);
|
|
|
+ Example.Criteria criteria = queryExample.createCriteria();
|
|
|
+ criteria.andEqualTo("id", unitBearingsPO.getId());
|
|
|
+ flg = unitBearingsMapper.updateByExampleSelective(unitBearingsPO, queryExample) > 0;
|
|
|
+ break outBearings;
|
|
|
+ }
|
|
|
+ // 创建
|
|
|
+ String unitBearingsCode = IdPrefixEnum.UNIT_BEARINGS_CODE.getCode().concat(IdGeneratorUtil.zeroFillUtil(cacheService.incr(ManagerRedisKeyConstant.build(ManagerRedisKeyConstant.IDGENERATOR_CONSTANTS_KEY, IdPrefixEnum.UNIT_BEARINGS_CODE.getCode()))));
|
|
|
+ unitBearingsPO.setMillTypeCode(unitDto.getMillTypeCode());
|
|
|
+ unitBearingsPO.setCode(unitBearingsCode);
|
|
|
+ unitBearingsPO.setCreateTime(new Date());
|
|
|
+ unitBearingsPO.setUpdateTime(new Date());
|
|
|
+ flg = unitBearingsMapper.insertUseGeneratedKeys(unitBearingsPO) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理发电机数据
|
|
|
+ outDynamo:
|
|
|
+ if (unitDto.getUnitDynamoDto() != null) {
|
|
|
+ UnitDynamoPO unitDynamoPO = new UnitDynamoPO();
|
|
|
+ BeanUtil.copyProperties(unitDto.getUnitDynamoDto(), unitDynamoPO);
|
|
|
+
|
|
|
+ //更新
|
|
|
+ if (unitDynamoPO.getId() != null && unitDynamoPO.getId() > 0) {
|
|
|
+ Example queryExample = new Example(UnitDynamoPO.class);
|
|
|
+ Example.Criteria criteria = queryExample.createCriteria();
|
|
|
+ criteria.andEqualTo("id", unitDynamoPO.getId());
|
|
|
+ flg = unitDynamoMapper.updateByExampleSelective(unitDynamoPO, queryExample) > 0;
|
|
|
+ break outDynamo;
|
|
|
+ }
|
|
|
+ // 创建
|
|
|
+ String unitDynamoCode = IdPrefixEnum.UNIT_GEAR_CODE.getCode().concat(IdGeneratorUtil.zeroFillUtil(cacheService.incr(ManagerRedisKeyConstant.build(ManagerRedisKeyConstant.IDGENERATOR_CONSTANTS_KEY, IdPrefixEnum.UNIT_DYNAMO_CODE.getCode()))));
|
|
|
+ unitDynamoPO.setMillTypeCode(unitDto.getMillTypeCode());
|
|
|
+ unitDynamoPO.setCode(unitDynamoCode);
|
|
|
+ unitDynamoPO.setCreateTime(new Date());
|
|
|
+ unitDynamoPO.setUpdateTime(new Date());
|
|
|
+ flg = unitDynamoMapper.insertUseGeneratedKeys(unitDynamoPO) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理齿轮箱总表数据
|
|
|
+ UnitGearboxPO unitGearboxPO = new UnitGearboxPO();
|
|
|
+ outunitGearbox:
|
|
|
+ if (unitDto.getUnitGearDto() != null) {
|
|
|
+ unitGearboxPO.setLubricantBrand(unitDto.getUnitGearDto().getLubricantBrand());
|
|
|
+ unitGearboxPO.setLubricantModel(unitDto.getUnitGearDto().getLubricantModel());
|
|
|
+ unitGearboxPO.setUpdateTime(new Date());
|
|
|
+ //更新齿轮箱总表
|
|
|
+ if (unitDto.getUnitGearDto().getId() != null && unitDto.getUnitGearDto().getId() > 0) {
|
|
|
+ unitGearboxPO.setId(unitDto.getUnitGearDto().getId());
|
|
|
+ Example queryExample = new Example(UnitDynamoPO.class);
|
|
|
+ Example.Criteria criteria = queryExample.createCriteria();
|
|
|
+ criteria.andEqualTo("id", unitGearboxPO.getId());
|
|
|
+ flg = unitGearboxMapper.updateByExampleSelective(unitGearboxPO, queryExample) > 0;
|
|
|
+ break outunitGearbox;
|
|
|
+ }
|
|
|
+ unitGearboxPO.setMillTypeCode(unitDto.getMillTypeCode());
|
|
|
+ String unitGearboxCode = IdPrefixEnum.UNIT_GEAR_CODE.getCode().concat(IdGeneratorUtil.zeroFillUtil(cacheService.incr(ManagerRedisKeyConstant.build(ManagerRedisKeyConstant.IDGENERATOR_CONSTANTS_KEY, IdPrefixEnum.UNIT_GEAR_CODE.getCode()))));
|
|
|
+ unitGearboxPO.setCode(unitGearboxCode);
|
|
|
+ unitGearboxPO.setCreateTime(new Date());
|
|
|
+ unitGearboxPO.setDelState(DeleteStatusEnum.NODELETE.getCode());
|
|
|
+ flg = unitGearboxMapper.insertUseGeneratedKeys(unitGearboxPO) > 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理齿轮箱轴承处理
|
|
|
+ if (!CollectionUtils.isEmpty(unitDto.getUnitGearDto().getUnitGearboxBearingsDtoList())) {
|
|
|
+ UnitGearboxBearingsPO unitGearboxBearingsPO = null;
|
|
|
+ List<UnitGearboxBearingsPO> unitGearboxBearingsPOList = Lists.newArrayList();
|
|
|
+ for (UnitDto.UnitGearboxBearingsDto dto : unitDto.getUnitGearDto().getUnitGearboxBearingsDtoList()) {
|
|
|
+ unitGearboxBearingsPO = new UnitGearboxBearingsPO();
|
|
|
+ BeanUtil.copyProperties(dto, unitGearboxBearingsPO);
|
|
|
+ unitGearboxBearingsPO.setGearboxCode(unitGearboxPO.getCode());
|
|
|
+ unitGearboxBearingsPO.setCreateTime(new Date());
|
|
|
+ unitGearboxBearingsPO.setUpdateTime(new Date());
|
|
|
+ unitGearboxBearingsPOList.add(unitGearboxBearingsPO);
|
|
|
+ }
|
|
|
+ UnitGearboxBearingsPO po = new UnitGearboxBearingsPO();
|
|
|
+ po.setGearboxCode(unitGearboxPO.getCode());
|
|
|
+ unitGearboxBearingsMapper.delete(po);
|
|
|
+
|
|
|
+ flg = unitGearboxBearingsMapper.insertList(unitGearboxBearingsPOList) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理齿轮箱结构
|
|
|
+ if (!CollectionUtils.isEmpty(unitDto.getUnitGearDto().getUnitGearboxStructureDtoList())) {
|
|
|
+ UnitGearboxStructurePO unitGearboxStructurePO = null;
|
|
|
+ List<UnitGearboxStructurePO> unitGearboxStructurePOList = Lists.newArrayList();
|
|
|
+ for (UnitDto.UnitGearboxStructureDto dto : unitDto.getUnitGearDto().getUnitGearboxStructureDtoList()) {
|
|
|
+ unitGearboxStructurePO = new UnitGearboxStructurePO();
|
|
|
+ BeanUtil.copyProperties(dto, unitGearboxStructurePO);
|
|
|
+ unitGearboxStructurePO.setGearboxCode(unitGearboxPO.getCode());
|
|
|
+ unitGearboxStructurePO.setCreateTime(new Date());
|
|
|
+ unitGearboxStructurePO.setUpdateTime(new Date());
|
|
|
+ unitGearboxStructurePOList.add(unitGearboxStructurePO);
|
|
|
+ }
|
|
|
+ UnitGearboxStructurePO po = new UnitGearboxStructurePO();
|
|
|
+ po.setGearboxCode(unitGearboxPO.getCode());
|
|
|
+ unitGearboxStructureMapper.delete(po);
|
|
|
+
|
|
|
+ flg = unitGearboxStructureMapper.insertList(unitGearboxStructurePOList) > 0;
|
|
|
+ }
|
|
|
+ return flg;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public UnitVo getUnitVo(String millTypeCode) {
|
|
|
+
|
|
|
+ UnitVo unitVo = new UnitVo();
|
|
|
+ unitVo.setMillTypeCode(millTypeCode);
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(millTypeCode)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 主轴
|
|
|
+ Example queryExample = new Example(UnitBearingsPO.class);
|
|
|
+ Example.Criteria criteria = queryExample.createCriteria();
|
|
|
+ criteria.andEqualTo("millTypeCode", millTypeCode);
|
|
|
+ UnitBearingsPO unitBearingsPO = unitBearingsMapper.selectOneByExample(queryExample);
|
|
|
+
|
|
|
+ UnitVo.UnitBearingsVo unitBearingsVo = new UnitVo.UnitBearingsVo();
|
|
|
+ BeanUtil.copyProperties(unitBearingsPO,unitBearingsVo);
|
|
|
+ unitVo.setUnitBearingsVo(unitBearingsVo);
|
|
|
+
|
|
|
+ // 发电机
|
|
|
+ Example queryUdExample = new Example(UnitDynamoPO.class);
|
|
|
+ Example.Criteria criteriaUd = queryUdExample.createCriteria();
|
|
|
+ criteriaUd.andEqualTo("millTypeCode", millTypeCode);
|
|
|
+ UnitDynamoPO unitDynamoPO = unitDynamoMapper.selectOneByExample(queryUdExample);
|
|
|
+
|
|
|
+ UnitVo.UnitDynamoVo unitDynamoVo = new UnitVo.UnitDynamoVo();
|
|
|
+ BeanUtil.copyProperties(unitDynamoPO,unitDynamoVo);
|
|
|
+ unitVo.setUnitDynamoVo(unitDynamoVo);
|
|
|
+
|
|
|
+ // 齿轮箱
|
|
|
+ UnitVo.UnitGearVo unitGearVo = new UnitVo.UnitGearVo();
|
|
|
+ Example queryUgExample = new Example(UnitGearboxPO.class);
|
|
|
+ Example.Criteria criteriaUg = queryUgExample.createCriteria();
|
|
|
+ criteriaUg.andEqualTo("millTypeCode", millTypeCode);
|
|
|
+
|
|
|
+ UnitGearboxPO unitGearboxPO = unitGearboxMapper.selectOneByExample(queryUgExample);
|
|
|
+ BeanUtil.copyProperties(unitGearboxPO,unitGearVo);
|
|
|
+
|
|
|
+ // 齿轮箱轴承
|
|
|
+ Example queryUgbExample = new Example(UnitGearboxBearingsPO.class);
|
|
|
+ Example.Criteria criteriaUgb = queryUgbExample.createCriteria();
|
|
|
+ criteriaUgb.andEqualTo("gearboxCode", unitGearboxPO.getCode());
|
|
|
+ List<UnitGearboxBearingsPO> unitGearboxBearingsPOList = unitGearboxBearingsMapper.selectByExample(queryUgbExample);
|
|
|
+
|
|
|
+ UnitVo.UnitGearboxBearingsVo unitGearboxBearingsVo = null;
|
|
|
+ List<UnitVo.UnitGearboxBearingsVo> unitGearboxBearingsVos = Lists.newArrayList();
|
|
|
+ for(UnitGearboxBearingsPO unitGearboxBearingsPO : unitGearboxBearingsPOList){
|
|
|
+ unitGearboxBearingsVo = new UnitVo.UnitGearboxBearingsVo();
|
|
|
+ BeanUtil.copyProperties(unitGearboxBearingsPO,unitGearboxBearingsVo);
|
|
|
+ unitGearboxBearingsVos.add(unitGearboxBearingsVo);
|
|
|
+ }
|
|
|
+ unitGearVo.setUnitGearboxBearingsList(unitGearboxBearingsVos);
|
|
|
+
|
|
|
+ // 齿轮箱结构
|
|
|
+ Example queryUgsExample = new Example(UnitGearboxStructurePO.class);
|
|
|
+ Example.Criteria criteriaUgs = queryUgbExample.createCriteria();
|
|
|
+ criteriaUgs.andEqualTo("gearboxCode", unitGearboxPO.getCode());
|
|
|
+ List<UnitGearboxStructurePO> unitGearboxStructurePOList = unitGearboxStructureMapper.selectByExample(queryUgbExample);
|
|
|
+
|
|
|
+ UnitVo.UnitGearboxStructureVo unitGearboxStructureVo = null;
|
|
|
+ List<UnitVo.UnitGearboxStructureVo> unitGearboxStructureVos = Lists.newArrayList();
|
|
|
+ for(UnitGearboxStructurePO unitGearboxStructurePO : unitGearboxStructurePOList){
|
|
|
+ unitGearboxStructureVo = new UnitVo.UnitGearboxStructureVo();
|
|
|
+ BeanUtil.copyProperties(unitGearboxStructurePO,unitGearboxStructureVo);
|
|
|
+ unitGearboxStructureVos.add(unitGearboxStructureVo);
|
|
|
+ }
|
|
|
+ unitGearVo.setUnitGearboxStructureList(unitGearboxStructureVos);
|
|
|
|
|
|
+ unitVo.setUnitGearVo(unitGearVo);
|
|
|
|
|
|
- return false;
|
|
|
+ return unitVo;
|
|
|
}
|
|
|
}
|