|
@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.activiti.bean.ActObj;
|
|
|
import com.platform.activiti.enums.ActApplyEnum;
|
|
|
-import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.cache.ConfigCache;
|
|
|
import com.platform.common.constant.CommonConstants;
|
|
|
import com.platform.common.enums.DataFilterTypeEnum;
|
|
@@ -15,7 +14,6 @@ import com.platform.common.enums.ResultCode;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.model.UserInfo;
|
|
|
import com.platform.common.util.*;
|
|
|
-import com.platform.dao.bean.MyPage;
|
|
|
import com.platform.dao.bean.MyVOPage;
|
|
|
import com.platform.dao.dto.check.CheckStandardDTO;
|
|
|
import com.platform.dao.dto.part.PartInfoDTO;
|
|
@@ -43,14 +41,16 @@ import com.platform.dao.mapper.part.PartTypeMapper;
|
|
|
import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
|
|
|
import com.platform.dao.mapper.sb.*;
|
|
|
import com.platform.dao.mapper.upms.SysDeptMapper;
|
|
|
-import com.platform.dao.mapper.upms.SysUserDeptMapper;
|
|
|
import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
import com.platform.dao.mapper.workplace.WorkplaceBacklogUserMapper;
|
|
|
import com.platform.dao.util.CustomExcelImportUtil;
|
|
|
+import com.platform.dao.util.ExcelUtil;
|
|
|
import com.platform.dao.util.MessageTemplateUtil;
|
|
|
import com.platform.dao.util.UserUtil;
|
|
|
+import com.platform.dao.util.compare.FieldComparedUtils;
|
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
|
import com.platform.dao.vo.SysUserVO;
|
|
|
+import com.platform.dao.vo.export.sb.ExportSbInfoVO;
|
|
|
import com.platform.dao.vo.query.upms.SysDeptVO;
|
|
|
import com.platform.dao.vo.sb.*;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
@@ -112,7 +112,7 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
|
|
|
private final SysDeptService sysDeptService;
|
|
|
|
|
|
- private final SysUserDeptMapper sysUserDeptMapper;
|
|
|
+ private final SbChangeLogMapper sbChangeLogMapper;
|
|
|
|
|
|
private final SbModelMapper sbModelMapper;
|
|
|
|
|
@@ -480,6 +480,11 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
}
|
|
|
setSaveDept(model);
|
|
|
setSbStatusLogAndStopLog(model);
|
|
|
+ // 保存修改记录
|
|
|
+ SbInfo sbInfo = mapper.selectByPrimaryKey(model.getId());
|
|
|
+ SbInfoDTO oldDTO = BeanConverterUtil.copyObjectProperties(sbInfo,SbInfoDTO.class);
|
|
|
+ String updateInfo = FieldComparedUtils.compareBean(oldDTO,model);
|
|
|
+ packageLogInfo(updateInfo,model.getId());
|
|
|
super.modModelByDTO(model);
|
|
|
// 保存文件
|
|
|
this.saveImageFile(model);
|
|
@@ -488,6 +493,19 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
this.saveRecheckFile(model);
|
|
|
}
|
|
|
|
|
|
+ private void packageLogInfo(String updateInfo,String sbId){
|
|
|
+ SbChangeLog log = new SbChangeLog();
|
|
|
+ log.setCreatedTime(LocalDateTime.now());
|
|
|
+ log.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
|
|
|
+ log.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
|
|
|
+ log.setId(IdGeneratorUtils.getObjectId());
|
|
|
+ log.setObjId(sbId);
|
|
|
+ log.setUpdateJson(updateInfo);
|
|
|
+ log.setObjType(SbChangeLogTypeEnum.SB.getValue());
|
|
|
+ sbChangeLogMapper.insert(log);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void modModelByDTOIgnore(SbInfoDTO model) {
|
|
|
/* SbModelVO sbModelVO = sbModelMapper.getById(model.getModelId());
|
|
@@ -641,6 +659,108 @@ public class SbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, SbInfo, SbI
|
|
|
return sbTreeVO;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String updateImportUpdateForLongYan(MultipartFile file) {
|
|
|
+ int addNum = 0;
|
|
|
+ List<FirmProducer> producerList = firmProducerMapper.selectAll(); // 生产厂商
|
|
|
+ List<SbPosition> positionList = sbPositionMapper.selectAll(); // 设备位置
|
|
|
+ List<SbType> typeList = sbTypeMapper.selectAll(); // 设备类型集合
|
|
|
+ List<SbInfo> updateList = new ArrayList<SbInfo>(); // 待修改集合
|
|
|
+ List<SysUser> users = sysUserMapper.selectAll(); // 用户集合
|
|
|
+ try {
|
|
|
+ List<ExportSbInfoVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportSbInfoVO.class, 1);
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ for(ExportSbInfoVO vo : list){
|
|
|
+ SbInfo tempInfo = BeanConverterUtil.copyObjectProperties(vo,SbInfo.class);
|
|
|
+ if(StringUtils.isNotBlank(vo.getTypeName())){ // 设备类型匹配
|
|
|
+ boolean findSbType = false;
|
|
|
+ for (SbType sbType : typeList) {
|
|
|
+ if (sbType.getName().equalsIgnoreCase(vo.getTypeName().trim())) {
|
|
|
+ tempInfo.setTypeId(sbType.getId());
|
|
|
+ findSbType = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!findSbType) {
|
|
|
+ throw new BusinessException("系统找不到该设备类型名称,请先添加设备类型, 设备类型名称" + vo.getTypeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(vo.getPositionName())){ // 设备位置匹配
|
|
|
+ boolean findPosition = false;
|
|
|
+ for (SbPosition position : positionList) {
|
|
|
+ if (position.getName().equalsIgnoreCase(vo.getPositionName().trim())) {
|
|
|
+ tempInfo.setPositionId(position.getId());
|
|
|
+ findPosition = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!findPosition) {
|
|
|
+ throw new BusinessException("系统找不到车间名称,请先添加车间, 车间名称" + vo.getPositionName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(vo.getProducerName())){ // 生产商匹配
|
|
|
+ boolean findProducer = false;
|
|
|
+ for (FirmProducer producer : producerList) {
|
|
|
+ if (producer.getName().equalsIgnoreCase(vo.getProducerName().trim())) {
|
|
|
+ tempInfo.setProducerId(producer.getId());
|
|
|
+ findProducer = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!findProducer) {
|
|
|
+ throw new BusinessException("找不到生产商,请先添加:" + vo.getProducerName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(vo.getSaveUserName())){ // 使用人员
|
|
|
+ boolean findSaveUser = false;
|
|
|
+ for (SysUser user : users) {
|
|
|
+ if (user.getRealName().equalsIgnoreCase(vo.getSaveUserName().trim())) {
|
|
|
+ tempInfo.setSaveUser(user.getUserId());
|
|
|
+ findSaveUser = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!findSaveUser) {
|
|
|
+ throw new BusinessException("找不到使用人员,请先添加, 名称" + vo.getSaveUserName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果计量设备
|
|
|
+ if(vo.getUseType() == SbUseType.BGCL.getValue()){
|
|
|
+ if(vo.getCheckDate() == null && vo.getNextCheckDate() == null){
|
|
|
+ throw new BusinessException("上次和下次检定日期,不能全部为空");
|
|
|
+ }
|
|
|
+ if(vo.getCheckPeriod() == null){
|
|
|
+ throw new BusinessException("检定周期不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateList.add(tempInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 执行更新操作和记录
|
|
|
+ updateListAndSaveChange(updateList);
|
|
|
+ return "总计更新:" + (updateList.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新和记录修改
|
|
|
+ * @param sbInfos
|
|
|
+ */
|
|
|
+ private void updateListAndSaveChange(List<SbInfo> sbInfos){
|
|
|
+ if(sbInfos.size() > 0){
|
|
|
+ for(SbInfo sbInfo : sbInfos){
|
|
|
+ SbInfoDTO afterDTO = BeanConverterUtil.copyObjectProperties(sbInfo,SbInfoDTO.class);
|
|
|
+ SbInfo old = mapper.selectByPrimaryKey(sbInfo.getId());
|
|
|
+ SbInfoDTO beforeDTO = BeanConverterUtil.copyObjectProperties(old,SbInfoDTO.class);
|
|
|
+ mapper.updateByPrimaryKeySelective(sbInfo);
|
|
|
+ String info = FieldComparedUtils.compareBean(beforeDTO,afterDTO);
|
|
|
+ packageLogInfo(info,sbInfo.getId()); // 保存修改记录
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void setSbNum(LocalDateTime now, SbInfoWorkplaceVO vo) {
|
|
|
|