|
@@ -81,31 +81,38 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
//取出之前模具的信息
|
|
|
Mould model = mouldMapper.selectById(mould.getPreUpdateId());
|
|
|
//查询当前模具编号的模具是否存在
|
|
|
- Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
- if (count > 0) {
|
|
|
- msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
- return msg;
|
|
|
- } else {
|
|
|
// if (mould.getProduceCompanyId() != null) {
|
|
|
// Company company = companyMapper.selectById(mould.getProduceCompanyId());
|
|
|
// mould.setProduceCompanyName(company.getCompanyName());
|
|
|
// mould.setArea(company.getCompanyAddress());
|
|
|
// }
|
|
|
- mould.setCreatorId(user.getId());
|
|
|
- mould.setCompanyId(model.getCompanyId());
|
|
|
- mould.setEquipmentId(model.getEquipmentId());
|
|
|
- mould.setProjectId(model.getProjectId());
|
|
|
- mould.setRunTimes(model.getRunTimes());
|
|
|
- mould.setProduceCompanyName(model.getProduceCompanyName());
|
|
|
- mould.setProduceCompanyId(model.getProduceCompanyId());
|
|
|
- mould.setArea(model.getArea());
|
|
|
- mouldMapper.insert(mould);
|
|
|
- msg.data = mould;
|
|
|
- //将之前的模具与项目和设备解绑
|
|
|
- model.setProjectId(null);
|
|
|
- model.setEquipmentId(null);
|
|
|
- mouldMapper.updateById(model);
|
|
|
+ String oldModelNo = model.getModelNo();
|
|
|
+ StringBuilder newMouldNo = new StringBuilder();
|
|
|
+ if (oldModelNo.indexOf("-") == -1) {
|
|
|
+ newMouldNo.append(oldModelNo).append("-").append("1");
|
|
|
+ } else {
|
|
|
+ int i = Integer.parseInt(oldModelNo.substring(oldModelNo.length()));
|
|
|
+ i++;
|
|
|
+ newMouldNo.append(oldModelNo.substring(0, oldModelNo.length() - 1)).append(i + "");
|
|
|
}
|
|
|
+ mould.setModelNo(newMouldNo.toString());
|
|
|
+ mould.setCreatorId(user.getId());
|
|
|
+ mould.setCompanyId(model.getCompanyId());
|
|
|
+ mould.setEquipmentId(model.getEquipmentId());
|
|
|
+ mould.setProjectId(model.getProjectId());
|
|
|
+ mould.setRunTimes(model.getRunTimes());
|
|
|
+ mould.setProduceCompanyName(model.getProduceCompanyName());
|
|
|
+ mould.setProduceCompanyId(model.getProduceCompanyId());
|
|
|
+ mould.setArea(model.getArea());
|
|
|
+ mould.setBelongProjectGrade(0 + "");
|
|
|
+ mouldMapper.insert(mould);
|
|
|
+ msg.data = mould;
|
|
|
+ //将之前的模具与项目和设备解绑
|
|
|
+ Mould m = new Mould();
|
|
|
+ m.setId(model.getId());
|
|
|
+ m.setProjectId(null);
|
|
|
+ m.setEquipmentId(null);
|
|
|
+ mouldMapper.updateById(model);
|
|
|
} else {
|
|
|
//普通创建模具
|
|
|
//查询当前模具编号的模具是否存在
|
|
@@ -152,12 +159,12 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
map.put("approve", 0);
|
|
|
} else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
//当前为系统管理员
|
|
|
- if(Constant.ASSETS_COMPANY == currentUser.getSubordinateType()){
|
|
|
+ if (Constant.ASSETS_COMPANY == currentUser.getSubordinateType()) {
|
|
|
map.put("update", 1);
|
|
|
map.put("download", 1);
|
|
|
map.put("view", 1);
|
|
|
map.put("approve", 0);
|
|
|
- }else if(Constant.PRODUCER_COMPANY == currentUser.getSubordinateType()){
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == currentUser.getSubordinateType()) {
|
|
|
map.put("update", 0);
|
|
|
map.put("download", 1);
|
|
|
map.put("view", 1);
|
|
@@ -473,7 +480,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
|
newsNotice.setNoticeType(Constant.EMERGENCY_TYPE);
|
|
|
newsNotice.setProjectName(project.getProjectName());
|
|
|
// newsNotice.setRefId(mould.getId());
|
|
|
- newsNotice.setContent(mou.getModelNo()+"-"+Constant.EMERGENCY_NOTICE);
|
|
|
+ newsNotice.setContent(mou.getModelNo() + "-" + Constant.EMERGENCY_NOTICE);
|
|
|
newsNoticeMapper.insert(newsNotice);
|
|
|
//通知该模具所属资产方的管理员
|
|
|
User user = userMapper.selectOne(new QueryWrapper<User>().eq("company_id", mould.getCompanyId()).eq("parent_id", 1));
|