Commit 6113d10c authored by suhuiguang's avatar suhuiguang

1.使用登记单据变更功能,详情接口

parent 6089fda8
package com.yeejoin.amos.boot.biz.common.annotation;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
public @interface FieldDisplayDefine {
String value();
/**
* 字段别名 兼容前端使用
*
* @return 别名key
*/
String alias() default "";
boolean isExist() default true;
}
...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jg.api.dto; ...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jg.api.dto;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
@Data @Data
public class BaseChangeDataDto { public class BaseChangeDataDto implements Serializable {
} }
package com.yeejoin.amos.boot.module.jg.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel(value = "字段描述")
public class DynamicColumnDto implements Serializable {
@ApiModelProperty("数据库字段列")
private String columnName;
@ApiModelProperty("字段值")
private String columnValue;
}
package com.yeejoin.amos.boot.module.jg.api.dto; package com.yeejoin.amos.boot.module.jg.api.dto;
import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class EquipRegisterChangeDataDto extends BaseChangeDataDto { public class EquipRegisterChangeDataDto extends BaseChangeDataDto {
@FieldDisplayDefine(value = "设备种类" ,isExist = false)
private String equList;
private String equCode; private String equCode;
private String equDefine; private String equDefine;
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto; import com.yeejoin.amos.boot.module.common.api.dto.DPFilterParamDto;
import com.yeejoin.amos.boot.module.jg.api.bo.JgBizCountDataBO; import com.yeejoin.amos.boot.module.jg.api.bo.JgBizCountDataBO;
import com.yeejoin.amos.boot.module.jg.api.dto.DynamicColumnDto;
import com.yeejoin.amos.boot.module.jg.api.dto.ReportAnalysisSearchDTO; import com.yeejoin.amos.boot.module.jg.api.dto.ReportAnalysisSearchDTO;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -183,5 +184,7 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> { ...@@ -183,5 +184,7 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
Page<Map<String,Object>> countBizFinishedNumForDPListDQJY(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto); Page<Map<String,Object>> countBizFinishedNumForDPListDQJY(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto);
Page<Map<String,Object>> countBizFinishedNumForDPListBGDJ(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto); Page<Map<String,Object>> countBizFinishedNumForDPListBGDJ(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto);
Page<Map<String,Object>> countBizFinishedNumForDPListZXBX(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto); Page<Map<String,Object>> countBizFinishedNumForDPListZXBX(@Param("page") Page<Map<String,Object>> page, @Param("orgCode") String orgCode, @Param("dto") DPFilterParamDto dpFilterParamForDetailDto);
void updateTechParamDynamic(@Param(value = "tableName") String tableName,@Param(value = "record") String record, @Param(value = "columns") List<DynamicColumnDto> columns);
} }
...@@ -105,6 +105,7 @@ ...@@ -105,6 +105,7 @@
where instance_id = #{instanceId} where instance_id = #{instanceId}
</update> </update>
<select id="getUserPhone" resultType="java.util.Map"> <select id="getUserPhone" resultType="java.util.Map">
SELECT phone SELECT phone
FROM "tzs_user_info" FROM "tzs_user_info"
...@@ -2297,4 +2298,15 @@ ...@@ -2297,4 +2298,15 @@
and (a.status <![CDATA[ <> ]]> '已作废') and (a.status <![CDATA[ <> ]]> '已作废')
) )
</select> </select>
<update id="updateTechParamDynamic">
<if test="columns != null and columns.size > 0">
update
${tableName}
set
<foreach collection="columns" item="column" separator=",">
${column.columnName} = ${column.columnValue}
</foreach>
where record = #{record}
</if>
</update>
</mapper> </mapper>
...@@ -4,11 +4,9 @@ import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy; ...@@ -4,11 +4,9 @@ import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.BizDataChangeServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.BizDataChangeServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.springframework.web.bind.annotation.PostMapping; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -27,16 +25,28 @@ public class BizDataChangeController { ...@@ -27,16 +25,28 @@ public class BizDataChangeController {
this.bizDataChangeService = bizDataChangeService; this.bizDataChangeService = bizDataChangeService;
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/{bizType}/save") @PostMapping(value = "/{bizType}/save")
@ApiOperation(value = "业务数据变更保存", httpMethod = "GET") @ApiOperation(value = "业务数据变更保存", httpMethod = "GET")
public ResponseModel<String> save(String applyNo, public ResponseModel<String> save(String applyNo,
@PathVariable String bizType, @PathVariable String bizType,
IBizDataChangeHandleStrategy.ModelType model, IBizDataChangeHandleStrategy.ModelType model,
Map<String, List<Map<String, Object>>> changeData) { Map<String, List<Map<String, Object>>> changeData) {
bizDataChangeService.save(applyNo,bizType, model, changeData); bizDataChangeService.save(applyNo, bizType, model, changeData);
return ResponseHelper.buildResponse("success"); return ResponseHelper.buildResponse("success");
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{bizType}/detail")
@ApiOperation(value = "查询可业务变更的字段及默认值", httpMethod = "GET")
public ResponseModel<Map<String, List<Map<String, Object>>>> getDetail(@RequestParam(required = false) String applyNo,
@PathVariable String bizType,
IBizDataChangeHandleStrategy.ModelType model,
@RequestParam(required = false) String bizId) {
Map<String, List<Map<String, Object>>> re = bizDataChangeService.queryDetail(applyNo, bizType, model, bizId);
return ResponseHelper.buildResponse(re);
}
} }
...@@ -18,8 +18,6 @@ public class ChangeItemFactory { ...@@ -18,8 +18,6 @@ public class ChangeItemFactory {
ITEM_FACTORY.put("equip_factory_info", EquipFactoryChangeDataDto.class); ITEM_FACTORY.put("equip_factory_info", EquipFactoryChangeDataDto.class);
// 设备-设计信息 // 设备-设计信息
ITEM_FACTORY.put("equip_design_info", EquipDesignChangeDataDto.class); ITEM_FACTORY.put("equip_design_info", EquipDesignChangeDataDto.class);
// 设备-技术参数
ITEM_FACTORY.put("equip_tech_param_info", EquipTechParamChangeDataDto.class);
} }
public static Class<? extends BaseChangeDataDto> getItemGroupClass(String group) { public static Class<? extends BaseChangeDataDto> getItemGroupClass(String group) {
......
...@@ -17,9 +17,10 @@ public interface IBizDataChangeHandleStrategy { ...@@ -17,9 +17,10 @@ public interface IBizDataChangeHandleStrategy {
* *
* @param applyNo 单据编号 * @param applyNo 单据编号
* @param model single, batch * @param model single, batch
* @param bizId
* @return 变更信息详情 * @return 变更信息详情
*/ */
Map<String, List<Map<String, Object>>> getChangeDetail(String applyNo, ModelType model); Map<String, List<Map<String, Object>>> getChangeDetail(String applyNo, ModelType model, String bizId);
/** /**
* 保存 * 保存
......
...@@ -15,6 +15,9 @@ public interface IChangeDataProcessStrategy { ...@@ -15,6 +15,9 @@ public interface IChangeDataProcessStrategy {
*/ */
Map<String, List<ChangeDataDto>> handle(List<Map<String, Object>> changeData, String defaultChangeId); Map<String, List<ChangeDataDto>> handle(List<Map<String, Object>> changeData, String defaultChangeId);
Map<String, List<Map<String, Object>>> getDetail(String applyNo, String bizId);
/** /**
* 可处理类型 * 可处理类型
* *
......
...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jg.biz.service.IChangeDataProcessStrategy; ...@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.module.jg.biz.service.IChangeDataProcessStrategy;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -25,6 +26,12 @@ public class BatchDataChangeProcessStrategy implements IChangeDataProcessStrateg ...@@ -25,6 +26,12 @@ public class BatchDataChangeProcessStrategy implements IChangeDataProcessStrateg
} }
@Override @Override
public Map<String, List<Map<String, Object>>> getDetail(String applyNo, String bizId) {
return Collections.emptyMap();
}
@Override
public IBizDataChangeHandleStrategy.ModelType canHandleMode() { public IBizDataChangeHandleStrategy.ModelType canHandleMode() {
return IBizDataChangeHandleStrategy.ModelType.batch; return IBizDataChangeHandleStrategy.ModelType.batch;
} }
......
...@@ -12,9 +12,10 @@ public class BizDataChangeServiceImpl { ...@@ -12,9 +12,10 @@ public class BizDataChangeServiceImpl {
/** /**
* 变更保存 * 变更保存
* @param applyNo 单据编号 *
* @param bizType 业务类型 * @param applyNo 单据编号
* @param model 单个维护、批量维护 * @param bizType 业务类型
* @param model 单个维护、批量维护
* @param changeData 变化后的数据 * @param changeData 变化后的数据
*/ */
public void save(String applyNo, public void save(String applyNo,
...@@ -24,4 +25,9 @@ public class BizDataChangeServiceImpl { ...@@ -24,4 +25,9 @@ public class BizDataChangeServiceImpl {
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType); IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
handleStrategy.doSave(applyNo, model, changeData); handleStrategy.doSave(applyNo, model, changeData);
} }
public Map<String, List<Map<String, Object>>> queryDetail(String applyNo, String bizType, IBizDataChangeHandleStrategy.ModelType model, String bizId) {
IBizDataChangeHandleStrategy handleStrategy = BizDataHandleStrategyContext.getStrategy(bizType);
return handleStrategy.getChangeDetail(applyNo, model, bizId);
}
} }
package com.yeejoin.amos.boot.module.jg.biz.service.impl; package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.support.jconsole.util.TableDataProcessor;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipDesignChangeDataDto; import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipFactoryChangeDataDto; import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.dto.EquipRegisterChangeDataDto;
import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgDesignInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgFactoryInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgFactoryInfo;
...@@ -14,10 +16,13 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo; ...@@ -14,10 +16,13 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgDesignInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgDesignInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgFactoryInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgFactoryInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import net.sf.jsqlparser.schema.Column;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
@Service @Service
public class EquipChangeDataUpdateService { public class EquipChangeDataUpdateService {
...@@ -30,11 +35,14 @@ public class EquipChangeDataUpdateService { ...@@ -30,11 +35,14 @@ public class EquipChangeDataUpdateService {
private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper; private final IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
public EquipChangeDataUpdateService(ESEquipmentCategory esEquipmentCategory, IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper, IdxBizJgFactoryInfoMapper jgFactoryInfoMapper, IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper) { private final CommonMapper commonMapper;
public EquipChangeDataUpdateService(ESEquipmentCategory esEquipmentCategory, IdxBizJgDesignInfoMapper idxBizJgDesignInfoMapper, IdxBizJgFactoryInfoMapper jgFactoryInfoMapper, IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper, CommonMapper commonMapper) {
this.esEquipmentCategory = esEquipmentCategory; this.esEquipmentCategory = esEquipmentCategory;
this.idxBizJgDesignInfoMapper = idxBizJgDesignInfoMapper; this.idxBizJgDesignInfoMapper = idxBizJgDesignInfoMapper;
this.jgFactoryInfoMapper = jgFactoryInfoMapper; this.jgFactoryInfoMapper = jgFactoryInfoMapper;
this.idxBizJgRegisterInfoMapper = idxBizJgRegisterInfoMapper; this.idxBizJgRegisterInfoMapper = idxBizJgRegisterInfoMapper;
this.commonMapper = commonMapper;
} }
public void updateRegisterChangeData(String record, EquipRegisterChangeDataDto registerChangeDataDto) { public void updateRegisterChangeData(String record, EquipRegisterChangeDataDto registerChangeDataDto) {
...@@ -116,4 +124,15 @@ public class EquipChangeDataUpdateService { ...@@ -116,4 +124,15 @@ public class EquipChangeDataUpdateService {
esEquipmentCategory.save(esEquipmentCategoryDto); esEquipmentCategory.save(esEquipmentCategoryDto);
} }
} }
public void updateTechParamByRecord(String tableName, String record, List<ChangeDataDto> changeDataDtos) {
List<DynamicColumnDto> columns = changeDataDtos.stream().map(c->{
DynamicColumnDto columnDto = new DynamicColumnDto();
columnDto.setColumnName(StrUtil.toUnderlineCase(c.getColumnKey()));
columnDto.setColumnValue(c.getColumnNewValue());
return columnDto;
}).collect(Collectors.toList());
// sql 动态构建入库
commonMapper.updateTechParamDynamic(tableName, record, columns);
}
} }
...@@ -144,7 +144,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -144,7 +144,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired @Autowired
DataDictionaryServiceImpl iDataDictionaryService; DataDictionaryServiceImpl iDataDictionaryService;
String[] jsonFields = {"productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain", public static final String[] jsonFields = {"productPhoto", "factoryStandard", "productQualityYieldProve", "insUseMaintainExplain",
"inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact", "inspectReport", "designStandard", "designDoc", "longitudeLatitude", "otherAccessoriesDes", "otherAccessoriesFact",
"otherAccessoriesReg", "installProxyStatementAttachment", "installContractAttachment", "insOtherAccessories", "otherAccessoriesReg", "installProxyStatementAttachment", "installContractAttachment", "insOtherAccessories",
"maintenanceContract", "maintOtherAccessories", "installProxyStatementAttachment", "installContractAttachment", "maintenanceContract", "maintOtherAccessories", "installProxyStatementAttachment", "installContractAttachment",
...@@ -1869,7 +1869,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -1869,7 +1869,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return detail; return detail;
} }
private String setDefaultRecord(JgUseRegistration jgUseRegistration, String record) { String setDefaultRecord(JgUseRegistration jgUseRegistration, String record) {
if (StringUtils.isEmpty(record)) { if (StringUtils.isEmpty(record)) {
JgUseRegistrationEq jgUseRegistrationEq = jgUseRegistrationEqService.getOne(new LambdaQueryWrapper<JgUseRegistrationEq>().eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr())); JgUseRegistrationEq jgUseRegistrationEq = jgUseRegistrationEqService.getOne(new LambdaQueryWrapper<JgUseRegistrationEq>().eq(JgUseRegistrationEq::getEquipTransferId, jgUseRegistration.getSequenceNbr()));
record = jgUseRegistrationEq.getEquId(); record = jgUseRegistrationEq.getEquId();
...@@ -2293,7 +2293,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -2293,7 +2293,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
* @param jgUseRegistration 使用信息 * @param jgUseRegistration 使用信息
* @param record 设备唯一标识 * @param record 设备唯一标识
*/ */
private void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) { void fillHistoryDataWithNewEquip(JSONObject jsonObject, JgUseRegistration jgUseRegistration, String record) {
// 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程 // 非已完成、非作废时显示设备最新信息。前置需求:一个设备只能同时发起一个流程
if (!(FlowStatusEnum.TO_BE_FINISHED.getName().equals(jgUseRegistration.getStatus()) if (!(FlowStatusEnum.TO_BE_FINISHED.getName().equals(jgUseRegistration.getStatus())
|| FlowStatusEnum.TO_BE_DISCARD.getName().equals(jgUseRegistration.getStatus())) || FlowStatusEnum.TO_BE_DISCARD.getName().equals(jgUseRegistration.getStatus()))
......
...@@ -7,11 +7,16 @@ import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher; ...@@ -7,11 +7,16 @@ import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.factory.ChangeItemFactory; import com.yeejoin.amos.boot.module.jg.biz.factory.ChangeItemFactory;
import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy; import com.yeejoin.amos.boot.module.jg.biz.service.IBizDataChangeHandleStrategy;
import com.yeejoin.amos.boot.module.jg.biz.service.IChangeDataProcessStrategy; import com.yeejoin.amos.boot.module.jg.biz.service.IChangeDataProcessStrategy;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStrategy { public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStrategy {
...@@ -36,8 +41,10 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -36,8 +41,10 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
} }
@Override @Override
public Map<String, List<Map<String, Object>>> getChangeDetail(String applyNo, ModelType model) { public Map<String, List<Map<String, Object>>> getChangeDetail(String applyNo, ModelType model, String bizId) {
return Collections.emptyMap(); IChangeDataProcessStrategy dataProcessor = DataProcessStrategyContext.getStrategy(model);
// 兼容:台套类打开变更详情(使用applyNo) 和 单位办理批量时选择单个设备打开详情(使用record)
return dataProcessor.getDetail(applyNo, bizId);
} }
/** /**
...@@ -48,16 +55,17 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -48,16 +55,17 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
* @param changeData 变更数据 key为不同的分组:如使用信息、设计信息、制造信息、技术参数 * @param changeData 变更数据 key为不同的分组:如使用信息、设计信息、制造信息、技术参数
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void doSave(String applyNo, ModelType model, Map<String, List<Map<String, Object>>> changeData) { public void doSave(String applyNo, ModelType model, Map<String, List<Map<String, Object>>> changeData) {
List<ChangeDataDto> allChangeColumns = new ArrayList<>(); List<ChangeDataDto> allChangeColumns = new ArrayList<>();
// 选择是台套、还是单位办理的方式,进行数据的解析 // 选择是台套、还是单位办理的方式,进行分类数据的解析
IChangeDataProcessStrategy dataProcessor = DataProcessStrategyContext.getStrategy(model); IChangeDataProcessStrategy dataProcessor = DataProcessStrategyContext.getStrategy(model);
changeData.forEach((k, v) -> { changeData.forEach((k, v) -> {
Map<String, List<ChangeDataDto>> columnsMap = new HashMap<>(); Map<String, List<ChangeDataDto>> columnsMap = new HashMap<>();
if (k.startsWith("biz")) { if (k.startsWith("biz")) {
// 单据信息变化 // TODO 单据信息变化 目前预览但是未使用到
columnsMap = dataProcessor.handle(v, applyNo); columnsMap = dataProcessor.handle(v, applyNo);
// 将前端json数据,格式化解析为java对象格式及数据比对去掉未变化的数据,key为record, value为字段数组 // 将前端json数据,格式化解析为java对象格式及数据比对去掉未变化的数据,key为applyNo, value为字段数组
columnsMap.forEach((a, columns) -> { columnsMap.forEach((a, columns) -> {
if (!columns.isEmpty()) { if (!columns.isEmpty()) {
// 将json列转为java-bean // 将json列转为java-bean
...@@ -71,7 +79,7 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -71,7 +79,7 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
} else if (k.startsWith("equip")) { } else if (k.startsWith("equip")) {
// 设备信息变化 // 设备信息变化
columnsMap = dataProcessor.handle(v, null); columnsMap = dataProcessor.handle(v, null);
// 将前端json数据,格式化解析为java对象格式及数据比对去掉未变化的数据,key为record, value为字段数组 // 将前端json数据,格式化解析为java对象格式及数据比对去掉未变化的数据,key为record, value为字段数组,代表设备所有发生变化的业务字段集合
columnsMap.forEach((record, columns) -> { columnsMap.forEach((record, columns) -> {
if (!columns.isEmpty()) { if (!columns.isEmpty()) {
// 将json列转为java-bean // 将json列转为java-bean
...@@ -82,16 +90,34 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -82,16 +90,34 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
this.buildLogData(allChangeColumns, columns, record, k); this.buildLogData(allChangeColumns, columns, record, k);
} }
}); });
} else if (k.startsWith("tech")) {
// 技术信息变化
columnsMap = dataProcessor.handle(v, null);
// 将前端json数据,格式化解析为java对象格式及数据比对去掉未变化的数据,key为record, value为字段数组,代表所有变化的技术参数字段集合
columnsMap.forEach((record, columns) -> {
if (!columns.isEmpty()) {
// 技术参数入库
equipChangeDataUpdateService.updateTechParamByRecord(this.buildTableName(k), record, columns);
// 日志数据构建
this.buildLogData(allChangeColumns, columns, record, k);
}
});
} }
}); });
// 更新历史的JSON的数据
this.updateHistoryJson(applyNo);
// 记录日志
if (!allChangeColumns.isEmpty()) { if (!allChangeColumns.isEmpty()) {
// 更新历史的JSON的数据
this.updateHistoryJson(applyNo);
// 异步记录日志
publisher.publish(new ChangeDataEvent(this, allChangeColumns, RequestContext.cloneRequestContext())); publisher.publish(new ChangeDataEvent(this, allChangeColumns, RequestContext.cloneRequestContext()));
} }
} }
private String buildTableName(String group) {
return String.format("%s_%s", "idx_biz_jg", group);
}
private void updateHistoryJson(String applyNo) { private void updateHistoryJson(String applyNo) {
useRegisterUpdateService.updateHisData(applyNo); useRegisterUpdateService.updateHisData(applyNo);
} }
...@@ -135,10 +161,6 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra ...@@ -135,10 +161,6 @@ public class UseRegisterDataChangeHandleImpl implements IBizDataChangeHandleStra
EquipRegisterChangeDataDto registerChangeDataDto = (EquipRegisterChangeDataDto) changeDataDto; EquipRegisterChangeDataDto registerChangeDataDto = (EquipRegisterChangeDataDto) changeDataDto;
equipChangeDataUpdateService.updateRegisterChangeData(record, registerChangeDataDto); equipChangeDataUpdateService.updateRegisterChangeData(record, registerChangeDataDto);
} }
// 新定义-不同的技术参数要单独处理表
if (changeDataDto instanceof EquipTechParamChangeDataDto) {
EquipTechParamChangeDataDto techParamChangeDataDto = (EquipTechParamChangeDataDto) changeDataDto;
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment