| | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.TechnicalSpecificationMapper; |
| | | import com.whyc.pojo.TechnicalSpecification; |
| | | import com.whyc.pojo.TechnicalSpecificationLockLog; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.DateUtil; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | private ProductHistoryService productHistoryService; |
| | | |
| | | @Autowired |
| | | private DocLogService logService; |
| | | private TechnicalSpecificationLockLogService lockLogService; |
| | | |
| | | public Response<Object> excelParse(InputStream inputStream) throws IOException, InvalidFormatException, ParseException { |
| | | TechnicalSpecification specification = new TechnicalSpecification(); |
| | |
| | | return new Response().set(1,false,"文件名,文件类型,版本,负责人,归档日期,物料编码,规格型号 中至少有一项为空"); |
| | | } |
| | | |
| | | //校验规格书文件名称=说明书中的文件名称+版本号 |
| | | //校验规格书附件名称=说明书中的文件名称+版本号 |
| | | String fileNameUnion = specification.getFileName() + specification.getVersion(); |
| | | String excelName = file2Name.substring(0,file2Name.lastIndexOf(".")); |
| | | if(!(fileNameUnion).equals(excelName)){ |
| | | return new Response().set(1,false,"技术规格书excel的命名与excel内的文件名+版本号称不一致"); |
| | | String attachmentName = file1Name.substring(0,file1Name.lastIndexOf(".")); |
| | | if(!(fileNameUnion).equals(attachmentName)){ |
| | | return new Response().set(1,false,"附件的命名与技术规格书excel内的文件名+版本号称不一致"); |
| | | } |
| | | //校验负责人是否存在 |
| | | boolean checkExists = userService.checkExists(specification.getOwner()); |
| | |
| | | specification.setCreateTime(date); |
| | | //锁定-负责人才能解锁 |
| | | specification.setLockFlag(1); |
| | | specification.setLockReason("系统默认锁定,新版本技术规则书上传"); |
| | | mapper.insert(specification); |
| | | //锁定适用机型的生效版本 |
| | | lockOtherByAppliedProduct(specification); |
| | | //锁定日志 |
| | | TechnicalSpecificationLockLog lockLog = new TechnicalSpecificationLockLog(); |
| | | lockLog.setUserName(ActionUtil.getUser().getName()); |
| | | lockLog.setTechnicalSpecificationId(specification.getId()); |
| | | lockLog.setReason("系统默认锁定,新版本技术规则书上传"); |
| | | lockLog.setCreateTime(date); |
| | | lockLog.setStatus(0); |
| | | lockLogService.add(lockLog); |
| | | return new Response().set(1,true,"上传完成"); |
| | | } |
| | | |
| | | private void lockOtherByAppliedProduct(TechnicalSpecification specification) { |
| | | UpdateWrapper<TechnicalSpecification> update = Wrappers.update(); |
| | | update.set("lock_flag",1); |
| | | update.set("lock_reason","系统默认锁定,新版本技术规则书上传,旧版本锁定"); |
| | | //update.set("lock_reason","系统默认锁定,新版本技术规则书上传,旧版本锁定"); |
| | | update.eq("apply_material_code",specification.getApplyMaterialCode()); |
| | | update.eq("apply_custom_code", specification.getApplyCustomCode()); |
| | | |
| | | update.eq("lock_flag",0); |
| | | update.last(" limit 1"); |
| | | |
| | | mapper.update(null,update); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response updateLock(int id, int lockFlag) { |
| | | public Response updateLock(int id, int lockFlag, String reason) { |
| | | Date date = new Date(); |
| | | String userName = ActionUtil.getUser().getName(); |
| | | TechnicalSpecification specificationInDB = get(id); |
| | | if(!userName.equals(specificationInDB.getOwner())){ |
| | |
| | | }else{ |
| | | //锁定目前生效版本 |
| | | availableVersion.setLockFlag(1); |
| | | availableVersion.setLockReason("新版本解锁,此旧版本锁定"); |
| | | mapper.updateById(availableVersion); |
| | | //锁定日志 |
| | | TechnicalSpecificationLockLog lockLog = new TechnicalSpecificationLockLog(); |
| | | lockLog.setUserName(userName); |
| | | lockLog.setTechnicalSpecificationId(id); |
| | | lockLog.setReason("新版本解锁,此旧版本锁定"); |
| | | lockLog.setCreateTime(date); |
| | | lockLog.setStatus(0); |
| | | lockLogService.add(lockLog); |
| | | } |
| | | } |
| | | } |
| | | specificationInDB.setLockFlag(lockFlag); |
| | | mapper.updateById(specificationInDB); |
| | | |
| | | //锁定/解锁日志 |
| | | TechnicalSpecificationLockLog lockLog = new TechnicalSpecificationLockLog(); |
| | | lockLog.setUserName(userName); |
| | | lockLog.setTechnicalSpecificationId(id); |
| | | lockLog.setReason(reason); |
| | | lockLog.setCreateTime(date); |
| | | lockLog.setStatus(lockFlag==1?0:1); |
| | | lockLogService.add(lockLog); |
| | | return new Response().set(1, true, "更新完成"); |
| | | } |
| | | |