质量异常提报完成

赵嘉伟 4 years ago
parent 9b7cf55726
commit 755d461717

@ -6,13 +6,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.anomaly.model.AbnormalBill;
import com.foreverwin.mesnac.anomaly.model.AbnormalBillDispose;
import com.foreverwin.mesnac.anomaly.service.AbnormalBillService;
import com.foreverwin.mesnac.meapi.controller.NcCodeController;
import com.foreverwin.mesnac.meapi.controller.WorkCenterController;
import com.foreverwin.mesnac.meapi.model.DataField;
import com.foreverwin.mesnac.meapi.model.NcCode;
import com.foreverwin.mesnac.meapi.model.WorkCenter;
import com.foreverwin.mesnac.meapi.service.DataFieldListService;
import com.foreverwin.mesnac.meapi.service.NcCodeService;
import com.foreverwin.mesnac.meapi.service.WorkCenterService;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.R;
@ -38,10 +37,7 @@ public class AbnormalBillController {
private NcCodeService ncCodeService;
@Autowired
private WorkCenterController workCenterController;
@Autowired
private NcCodeController ncCodeController;
private WorkCenterService workCenterService;
@Autowired
private DataFieldListService dataFieldListService;
@ -181,14 +177,15 @@ public class AbnormalBillController {
//工作中心
WorkCenter workCenter = new WorkCenter();
workCenter.setWcCategory("LEVEL4");
R workCenterList = workCenterController.getWorkCenterList(workCenter);
workCenter.setSite(site);
List<WorkCenter> workCenterList = workCenterService.selectList(workCenter);
hashMap.put("workCenter",workCenterList);
//原因分类
NcCode ncCode = new NcCode();
ncCode.setSite(site);
ncCode.setNcCategory("REPAIR");
R causeType = ncCodeController.getNcCodeList(ncCode);
hashMap.put("causeType",causeType);
List<NcCode> ncCodeList = ncCodeService.selectList(ncCode);
hashMap.put("causeType",ncCodeList);
//责任部门
DataField dataField = new DataField();
dataField.setSite(site);
@ -208,15 +205,34 @@ public class AbnormalBillController {
// }
/**
*
*
* @param abnormalBill
* @return
*/
@GetMapping("/anomalyReportOther")
public R anomalyReportOther(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose){
return R.ok(abnormalBillService.anomalyReportOther(abnormalBill, abnormalBillDispose));
public R anomalyReportOther(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
@RequestParam List<String> dutyCauseType,
@RequestParam List<String> dutyType){
return R.ok(abnormalBillService.anomalyReportOther(abnormalBill, abnormalBillDispose,dutyCauseType,dutyType));
}
/**
*
* @param abnormalBill
* @param abnormalBillDispose
* @return
*/
@GetMapping("/anomalyReport")
public R anomalyReport(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
@RequestParam List<String> ncGroupAndNcCodes,
@RequestParam List<String> dutyCauseType,
@RequestParam List<String> dutyType){
return R.ok(abnormalBillService.anomalyReport(abnormalBill, abnormalBillDispose,ncGroupAndNcCodes,dutyCauseType,dutyType));
}
/**
*
* @param handle

@ -46,6 +46,8 @@ public class AbnormalCauseController {
@GetMapping("")
public R getAbnormalCauseList(AbnormalCause abnormalCause){
List<AbnormalCause> result;
String site = CommonMethods.getSite();
abnormalCause.setSite(site);
QueryWrapper<AbnormalCause> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(abnormalCause);
result = abnormalCauseService.list(queryWrapper);

@ -46,6 +46,8 @@ public class AbnormalDutyController {
@GetMapping("")
public R getAbnormalDutyList(AbnormalDuty abnormalDuty){
List<AbnormalDuty> result;
String site = CommonMethods.getSite();
abnormalDuty.setSite(site);
QueryWrapper<AbnormalDuty> queryWrapper = new QueryWrapper<>();
queryWrapper.setEntity(abnormalDuty);
result = abnormalDutyService.list(queryWrapper);

@ -1,7 +1,7 @@
package com.foreverwin.mesnac.anomaly.mapper;
import com.foreverwin.mesnac.anomaly.model.AbnormalDuty;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.foreverwin.mesnac.anomaly.model.AbnormalDuty;
import org.springframework.stereotype.Repository;
/**

@ -27,14 +27,23 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
List<AbnormalBill> selectList(AbnormalBill abnormalBill);
String anomalyReportOther(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose);
String anomalyReportOther(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
List<String> dutyCauseType,
List<String> dutyType);
String anomalyReport(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
List<String> ncGroupAndNcCodes,
List<String> dutyCauseType,
List<String> dutyType);
/**
*
* @param abnormalBill
* @param abnormalBillDispose
*/
void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose);
void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType);
void cancelBrowse(String handle,String cancelBrowse);

@ -25,4 +25,5 @@ public interface AbnormalDutyService extends IService<AbnormalDuty> {
IPage<AbnormalDuty> selectPage(FrontPage<AbnormalDuty> frontPage, AbnormalDuty abnormalDuty);
List<AbnormalDuty> selectList(AbnormalDuty abnormalDuty);
}

@ -25,4 +25,5 @@ public interface AbnormalNcCodeService extends IService<AbnormalNcCode> {
IPage<AbnormalNcCode> selectPage(FrontPage<AbnormalNcCode> frontPage, AbnormalNcCode abnormalNcCode);
List<AbnormalNcCode> selectList(AbnormalNcCode abnormalNcCode);
}

@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillMapper;
import com.foreverwin.mesnac.anomaly.model.AbnormalBill;
import com.foreverwin.mesnac.anomaly.model.AbnormalBillDispose;
import com.foreverwin.mesnac.anomaly.service.AbnormalBillDisposeService;
import com.foreverwin.mesnac.anomaly.service.AbnormalBillService;
import com.foreverwin.mesnac.anomaly.model.*;
import com.foreverwin.mesnac.anomaly.service.*;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
import com.foreverwin.mesnac.common.util.StringUtil;
@ -24,7 +22,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.*;
/**
* <p>
*
@ -56,6 +55,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
private NwaUserService nwaUserService;
@Autowired
private AbnormalNcCodeService abnormalNcCodeService;
@Autowired
private AbnormalCauseService abnormalCauseService;
@Autowired
private AbnormalDutyService abnormalDutyService;
@Override
public IPage<AbnormalBill> selectPage(FrontPage<AbnormalBill> frontPage, AbnormalBill abnormalBill) {
@ -72,40 +80,147 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
@Override
public String anomalyReportOther(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose) {
this.generateAbnormalBill(abnormalBill,abnormalBillDispose);
public String anomalyReportOther(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
List<String> dutyCauseType,
List<String> dutyType) {
this.generateAbnormalBill(abnormalBill,abnormalBillDispose,dutyCauseType,dutyType);
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
return abnormalBill.getAbnormalNo();
}
@Override
public void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose) {
public String anomalyReport(AbnormalBill abnormalBill,
AbnormalBillDispose abnormalBillDispose,
List<String> ncGroupAndNcCodes,
List<String> dutyCauseType,
List<String> dutyType) {
this.generateAbnormalBill(abnormalBill,abnormalBillDispose,dutyCauseType,dutyType);
//获取当前时间
LocalDateTime now = LocalDateTime.now();
//生成不良代码和不良代码组,并把它放到hashMap里面ncCode是存放在异常单里面的ncCode
List<String> ncCode = new ArrayList<>();
List<String> ncGroup = new ArrayList<>();
StringBuilder ncCodes = new StringBuilder();
for(String ncGroupAndNcCode:ncGroupAndNcCodes){
String[] split = ncGroupAndNcCode.split("/");
ncGroup.add(split[0]);
ncCode.add(split[1]);
ncCodes.append(split[1]).append(",");
}
ArrayList<AbnormalNcCode> abnormalNcCodes = new ArrayList<>();
for(int i = 0; i < ncGroup.size(); i ++){
AbnormalNcCode abnormalNcCode = new AbnormalNcCode();
//设置异常单BO
abnormalNcCode.setAbnormalBillBo(abnormalBill.getHandle());
List<AbnormalNcCode> abnormalNcCodes1 = abnormalNcCodeService.selectList(abnormalNcCode);
if(abnormalNcCodes1.size() != 0){
QueryWrapper<AbnormalNcCode> abnormalNcCodeQueryWrapper = new QueryWrapper<>();
abnormalNcCodeQueryWrapper.setEntity(abnormalNcCode);
abnormalNcCodeService.remove(abnormalNcCodeQueryWrapper);
}
abnormalNcCode.setModifiedUser(CommonMethods.getUser());
abnormalNcCode.setModifiedDateTime(now);
abnormalNcCode.setCreatedUser(CommonMethods.getUser());
abnormalNcCode.setCreatedDateTime(now);
//设置HANDLE
abnormalNcCode.setHandle(UUID.randomUUID().toString());
//设置站点
abnormalNcCode.setSite(CommonMethods.getSite());
//设置不合格代码组
abnormalNcCode.setNcCodeGroup(ncGroup.get(i));
abnormalNcCode.setNcCode(ncCode.get(i));
abnormalNcCodes.add(abnormalNcCode);
}
abnormalNcCodeService.saveOrUpdateBatch(abnormalNcCodes);
abnormalBill.setNcCode(ncCodes.substring(0,ncCodes.length() - 1));
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
return abnormalBill.getAbnormalNo();
}
@Override
public void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType) {
String site = CommonMethods.getSite();
LocalDateTime currentTime = LocalDateTime.now();
String user = CommonMethods.getUser();
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())){
String abnormalNo = null;
//生成异常单号
if("Q".equals(abnormalBill.getType())){//其他异常
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_OTHER", 1, null).get(0);
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_OTHER", 1, null).get(0);
}else if("Z".equals(abnormalBill.getType())){//质量异常
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_QUALITY", 1, null).get(0);
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_QUALITY", 1, null).get(0);
}else if("S".equals(abnormalBill.getType())){//设备异常
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_DEVICE", 1, null).get(0);
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_DEVICE", 1, null).get(0);
}
abnormalBill.setAbnormalNo(abnormalNo);
}
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(abnormalBill.getSite(),abnormalBill.getAbnormalNo()));
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
abnormalBillDispose.setAbnormalBillBo(abnormalBill.getHandle());
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(abnormalBill.getSite(),abnormalBill.getAbnormalNo()));
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
LocalDateTime currentTime = LocalDateTime.now();
String user = CommonMethods.getUser();
//设置责任划分填报人和填报时间
abnormalBillDispose.setDutyUser(user);
abnormalBillDispose.setDutyDateTime(currentTime);
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
//判断原因分类是否为空
if(dutyCauseType.size() >= 1){
for(String cause:dutyCauseType){
AbnormalCause abnormalCause = new AbnormalCause();
String uuid = UUID.randomUUID().toString();
abnormalCause.setSite(site);
abnormalCause.setAbnormalBillBo(abnormalBill.getHandle());
abnormalCause.setAbnormalBillDisposeBo(abnormalBillDispose.getHandle());
List<AbnormalCause> abnormalCauses = abnormalCauseService.selectList(abnormalCause);
if(abnormalCauses.size() != 0){
QueryWrapper<AbnormalCause> abnormalCauseQueryWrapper = new QueryWrapper<>();
abnormalCauseQueryWrapper.setEntity(abnormalCause);
abnormalCauseService.remove(abnormalCauseQueryWrapper);
}
abnormalCause.setHandle(uuid);
abnormalCause.setAbnormalCauseNo(cause);
abnormalCause.setCreatedDateTime(currentTime);
abnormalCause.setCreatedUser(user);
abnormalCause.setModifiedUser(user);
abnormalCause.setModifiedDateTime(currentTime);
causeTypes.add(abnormalCause);
}
}
ArrayList<AbnormalDuty> dutyTypes = new ArrayList<>();
//判断责任分类是否为空
if(dutyType.size() >= 1){
for(String duty:dutyType){
AbnormalDuty abnormalDuty = new AbnormalDuty();
String uuid = UUID.randomUUID().toString();
abnormalDuty.setSite(site);
abnormalDuty.setAbnormalBillBo(abnormalBill.getHandle());
abnormalDuty.setAbnormalBillDisposeBo(abnormalBillDispose.getHandle());
List<AbnormalDuty> abnormalDuties = abnormalDutyService.selectList(abnormalDuty);
if(abnormalDuties.size() != 0){
QueryWrapper<AbnormalDuty> abnormalDutyQueryWrapper = new QueryWrapper<>();
abnormalDutyQueryWrapper.setEntity(abnormalDuty);
abnormalDutyService.remove(abnormalDutyQueryWrapper);
}
abnormalDuty.setHandle(uuid);
abnormalDuty.setAbnormalDutyNo(duty);
abnormalDuty.setModifiedUser(user);
abnormalDuty.setModifiedDateTime(currentTime);
abnormalDuty.setCreatedDateTime(currentTime);
abnormalDuty.setCreatedUser(user);
dutyTypes.add(abnormalDuty);
}
}
//设置创建时间和更新时间
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) == null){
abnormalBill.setCreatedDataTime(currentTime);
@ -126,17 +241,37 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
throw BusinessException.build("设备编号不能为空");
}
if(!StringUtil.isBlank(abnormalBill.getMessageType())){
NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(abnormalBill.getSite(), abnormalBill.getMessageType()));
NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(site, abnormalBill.getMessageType()));
if(messageType == null){
throw BusinessException.build("该消息类型不存在");
}
}
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(abnormalBill.getSite(), abnormalBill.getResrce()));
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, abnormalBill.getResrce()));
if(resrce == null){
throw BusinessException.build("该设备编号不存在");
}
//判断不良品数量和问题数量是否为正整数
try {
if(Integer.parseInt(abnormalBill.getNcQty()) < 0) {
throw BusinessException.build("不良品数量必须大于0");
}
if(Integer.parseInt(abnormalBill.getPbQty()) < 0){
throw BusinessException.build("问题数量必须大于0");
}
}catch (NumberFormatException num){
throw BusinessException.build("问题数量或不良品数量必须为一个正整数");
}
//判断输入的用户组是否正确,并返回对应的用户
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
//插入原因分类和责任分类
if(dutyTypes.size() > 0){
abnormalDutyService.saveOrUpdateBatch(dutyTypes);
}
if(causeTypes.size() > 0){
abnormalCauseService.saveOrUpdateBatch(causeTypes);
}
}
@Override

@ -43,4 +43,6 @@ public class AbnormalDutyServiceImpl extends ServiceImpl<AbnormalDutyMapper, Abn
}
}

@ -382,5 +382,4 @@
</foreach>)
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
</mapper>

@ -46,6 +46,8 @@ public class NcCodeController {
public R getNcCodeList(NcCode ncCode){
List<NcCode> result;
QueryWrapper<NcCode> queryWrapper = new QueryWrapper<>();
String site = CommonMethods.getSite();
ncCode.setSite(site);
queryWrapper.setEntity(ncCode);
result = ncCodeService.list(queryWrapper);
return R.ok(result);

@ -46,6 +46,8 @@ public class NcGroupController {
public R getNcGroupList(NcGroup ncGroup){
List<NcGroup> result;
QueryWrapper<NcGroup> queryWrapper = new QueryWrapper<>();
String site = CommonMethods.getSite();
ncGroup.setSite(site);
queryWrapper.setEntity(ncGroup);
result = ncGroupService.list(queryWrapper);
return R.ok(result);

@ -183,12 +183,12 @@
<if test="ew.entity.dpmoCategoryBo!=null"> AND DPMO_CATEGORY_BO=#{ew.entity.dpmoCategoryBo}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
AND ${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
AND ${ew.sqlSegment}
</if>
</select>

@ -180,12 +180,12 @@
<if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if>
</if>
<if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere">
${ew.sqlSegment}
AND ${ew.sqlSegment}
</if>
</if>
</where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">
${ew.sqlSegment}
AND ${ew.sqlSegment}
</if>
</select>

Loading…
Cancel
Save