use of com.eservice.api.model.contract_sign.ContractSign in project sinsim by WilsonHu.
the class CommonService method getCurrentSignStep.
// public String gatewayIpFromDockerFile ="aaa"; //main是静态域,所以不方便从main参数里获取值,已改为从文件里读取。
/**
* 用于返回对应合同的所有签核记录,每一次提交审核以后,都需要通过该API获取所有审核内容,再设置审核状态
*
* @param contractId
* @return result, 如果签核流程不存在返回null, 未结束则返回正在签核中的名称,结束则返回“FINISHED”
*/
public String getCurrentSignStep(Integer contractId) {
String result = null;
// 通过合同号找到有效的订单签核记录
List<OrderSign> orderSignList = orderSignService.getValidOrderSigns(contractId);
// 找到有效的合同签核记录,其实就是最新的合同簽和記錄
ContractSign contractSign1 = contractSignService.detailByContractId(String.valueOf(contractId));
HashMap<Integer, List<SignContentItem>> signContentSortByNumberMap = new HashMap<>();
for (OrderSign os : orderSignList) {
String contentStr = os.getSignContent();
List<SignContentItem> orderSignContentList = JSON.parseArray(contentStr, SignContentItem.class);
for (SignContentItem item : orderSignContentList) {
if (signContentSortByNumberMap.get(item.getNumber()) != null) {
signContentSortByNumberMap.get(item.getNumber()).add(item);
} else {
List<SignContentItem> list = new ArrayList<>();
list.add(item);
signContentSortByNumberMap.put(item.getNumber(), list);
}
}
}
List<SignContentItem> contractSignContentList = JSONObject.parseArray(contractSign1.getSignContent(), SignContentItem.class);
for (SignContentItem item : contractSignContentList) {
if (signContentSortByNumberMap.get(item.getNumber()) != null) {
signContentSortByNumberMap.get(item.getNumber()).add(item);
} else {
List<SignContentItem> list = new ArrayList<>();
list.add(item);
signContentSortByNumberMap.put(item.getNumber(), list);
}
}
// 签核流程不存在
if (signContentSortByNumberMap.size() == 0) {
return result;
}
// 将map.entrySet()转换成list
List<Map.Entry<Integer, List<SignContentItem>>> list = new ArrayList<>(signContentSortByNumberMap.entrySet());
// 通过比较器来实现排序
Collections.sort(list, new Comparator<Map.Entry<Integer, List<SignContentItem>>>() {
@Override
public int compare(Map.Entry<Integer, List<SignContentItem>> o1, Map.Entry<Integer, List<SignContentItem>> o2) {
// 升序排序
return o1.getKey().compareTo(o2.getKey());
}
});
Iterator<Map.Entry<Integer, List<SignContentItem>>> entries = signContentSortByNumberMap.entrySet().iterator();
boolean currentStepFound = false;
while (entries.hasNext() && !currentStepFound) {
Map.Entry<Integer, List<SignContentItem>> entry = entries.next();
Integer key = entry.getKey();
List<SignContentItem> value = entry.getValue();
for (SignContentItem item : value) {
// 根據簽和順序,找到最先的被拒絕或者未簽合的流程
if (item.getResult().equals(Constant.SIGN_REJECT) || item.getResult().equals(Constant.SIGN_INITIAL)) {
List<Role> roleList = roleService.findAll();
for (Role role : roleList) {
if (role.getId().equals(item.getRoleId())) {
result = role.getRoleName();
}
}
currentStepFound = true;
}
}
}
// 如果没有找到,表示该签核流程已经完成,此时返回一个特殊的String给调用者
if (!currentStepFound) {
result = Constant.SIGN_FINISHED;
}
return result;
}
use of com.eservice.api.model.contract_sign.ContractSign in project sinsim by WilsonHu.
the class ContractSignController method add.
@PostMapping("/add")
public Result add(String contractSign) {
ContractSign contractSign1 = JSON.parseObject(contractSign, ContractSign.class);
contractSignService.save(contractSign1);
return ResultGenerator.genSuccessResult();
}
use of com.eservice.api.model.contract_sign.ContractSign in project sinsim by WilsonHu.
the class ContractController method add.
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
public Result add(String contract, String contractSign, String requisitionForms) {
if (contract == null || "".equals(contract)) {
return ResultGenerator.genFailResult("合同信息为空!");
}
if (contractSign == null || "".equals(contractSign)) {
return ResultGenerator.genFailResult("合同审核初始化信息为空!");
}
if (requisitionForms == null || "".equals(requisitionForms)) {
return ResultGenerator.genFailResult("订单信息为空!");
}
Contract contract1 = JSONObject.parseObject(contract, Contract.class);
if (contract1 == null) {
return ResultGenerator.genFailResult("Contract对象JSON解析失败!");
}
// Condition condition = new Condition(Contract.class);
// condition.createCriteria().andCondition("contract_num = ", contract1.getContractNum());
// List<Contract> list = contractService.findByCondition(condition);
List<Contract> list = contractService.isContractExist(contract1.getContractNum());
if (list.size() != 0) {
logger.error("合同编号已存在");
return ResultGenerator.genFailResult("合同编号已存在!请换一个编号");
}
contract1.setCreateTime(new Date());
contractService.saveAndGetID(contract1);
Integer contractId = contract1.getId();
// /插入contract审核记录
ContractSign contractSignObj = new ContractSign();
contractSignObj.setContractId(contractId);
contractSignObj.setCreateTime(new Date());
contractSignObj.setSignContent(contractSign);
// /新增合同签核记录时,插入空值
contractSignObj.setCurrentStep("");
contractSignService.save(contractSignObj);
// 插入需求单记录
List<MachineOrderWrapper> machineOrderWapperList = JSONObject.parseArray(requisitionForms, MachineOrderWrapper.class);
if (machineOrderWapperList != null) {
// 是内贸还是外贸的订单
String salesDepartment = null;
User machineOrderCreator = null;
for (int i = 0; i < machineOrderWapperList.size(); i++) {
OrderDetail temp = machineOrderWapperList.get(i).getOrderDetail();
MachineOrder orderTemp = machineOrderWapperList.get(i).getMachineOrder();
orderDetailService.saveAndGetID(temp);
orderTemp.setOrderDetailId(temp.getId());
orderTemp.setContractId(contractId);
orderTemp.setStatus(Constant.ORDER_INITIAL);
Condition condition2 = new Condition(Contract.class);
condition2.createCriteria().andCondition("order_num = ", orderTemp.getOrderNum()).andCondition("valid = ", 1);
List<MachineOrder> orderList = machineOrderService.findByCondition(condition2);
if (orderList.size() != 0) {
logger.error("订单号已存在!请换一个");
return ResultGenerator.genFailResult("订单号已存在!请换一个");
}
machineOrderService.saveAndGetID(orderTemp);
// 初始化需求单审核记录
OrderSign orderSignData = machineOrderWapperList.get(i).getOrderSign();
OrderSign orderSign = new OrderSign();
orderSign.setSignContent(orderSignData.getSignContent());
orderSign.setOrderId(orderTemp.getId());
orderSign.setCreateTime(new Date());
orderSign.setCurrentStep("");
// 是内贸还是外贸 --> 因为要查询订单是哪个部门,所以要细化到外贸一部还是二部
if (salesDepartment == null) {
machineOrderCreator = userService.findById(orderTemp.getCreateUserId());
if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_DOMESTIC)) {
salesDepartment = Constant.STR_DEPARTMENT_DOMESTIC;
} else if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_FOREIGN_1)) {
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_1;
} else if (machineOrderCreator.getMarketGroupName().equals(Constant.STR_DEPARTMENT_FOREIGN_2)) {
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_2;
} else if (machineOrderCreator.getRoleId() == Constant.ROLE_ID_FOREIGN_DIRECTOR) {
/**
* 外贸总监的MarketGroupName部门为空, 外贸总监录的订单,也算为一部的。
* 外贸经理的MarketGroupName部门为外贸二部
*/
salesDepartment = Constant.STR_DEPARTMENT_FOREIGN_1;
}
orderSign.setSalesDepartment(salesDepartment);
}
orderSignService.saveAndGetID(orderSign);
// 第一个轮到签核的人也发消息推送 --> 此时为未提交状态,不需要发推送
}
} else {
// 手动回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return ResultGenerator.genFailResult("需求单为空!");
}
// 返回ID给前端,前端新增合同时不关闭页面。
return ResultGenerator.genSuccessResult(contract1.getId());
}
use of com.eservice.api.model.contract_sign.ContractSign in project sinsim by WilsonHu.
the class ContractController method changeOrder.
/**
* 联系单审核通过才允许改单,
* 改单后新生成的订单不用再审批,因为联系单已经审核过了。
*/
@PostMapping("/changeOrder")
@Transactional(rollbackFor = Exception.class)
public Result changeOrder(String contract, String contractSign, String requisitionForms) {
logger.info("changeOrder=======:");
logger.info(requisitionForms);
if (contract == null || "".equals(contract)) {
return ResultGenerator.genFailResult("合同信息为空!");
}
if (contractSign == null || "".equals(contractSign)) {
return ResultGenerator.genFailResult("合同审核初始化信息为空!");
}
if (requisitionForms == null || "".equals(requisitionForms)) {
return ResultGenerator.genFailResult("订单信息为空!");
}
Contract contract1 = JSONObject.parseObject(contract, Contract.class);
if (contract1 == null) {
return ResultGenerator.genFailResult("Contract对象JSON解析失败!");
}
// 更改合同的状态为“改单”
contract1.setStatus(Constant.CONTRACT_CHANGED);
contract1.setUpdateTime(new Date());
contractService.update(contract1);
Integer contractId = contract1.getId();
// /插入新的contract审核记录
ContractSign contractSignObj = new ContractSign();
contractSignObj.setContractId(contractId);
contractSignObj.setCreateTime(new Date());
contractSignObj.setSignContent(contractSign);
// /插入空值
contractSignObj.setCurrentStep("");
contractSignService.save(contractSignObj);
// 新增的改单处理
// 返回新增的改单的ID号给前端,前端新增改单时不关闭页面。
int newMachineOrderId = 0;
List<MachineOrderWrapper> machineOrderWrapperList = JSONObject.parseArray(requisitionForms, MachineOrderWrapper.class);
for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
MachineOrder machineOrder = orderItem.getMachineOrder();
// 检查时候存在有效的需求单,如果需求单中存在ID,则表示其已经在数据库中存在;修复同一个合同中多次改单(未提交审核)出现重复的需求单的问题
if (machineOrder.getStatus().equals(Constant.ORDER_INITIAL) && machineOrder.getOriginalOrderId() != 0 && (machineOrder.getId() == null || machineOrder.getId() == 0)) {
// 插入新增改单项的detail
OrderDetail temp = orderItem.getOrderDetail();
orderDetailService.saveAndGetID(temp);
machineOrder.setOrderDetailId(temp.getId());
machineOrder.setContractId(contract1.getId());
// 改单的前提是原订单已审核完成,联系单已经审核通过,所以不需要再重新审核,
machineOrder.setStatus(Constant.ORDER_CHANGE_FINISHED);
machineOrder.setCreateTime(new Date());
machineOrderService.saveAndGetID(machineOrder);
// /设计单里的状态 也要改 -->改的地方多,统一放在定时器里去更新状态-->废弃,因为订单可能很多
newMachineOrderId = machineOrder.getId();
/**
* 为了让改单后的新订单也能看到签核的时间等,改单新生成的订单,也有对应的审核记录,
* 审核内容和步骤,来自于旧的审核记录。(和原订单的一样的签核记录)
*/
// 初始化需求单审核记录
OrderSign orderSignData = orderItem.getOrderSign();
OrderSign orderSign = new OrderSign();
orderSign.setSignContent(orderSignData.getSignContent());
orderSign.setOrderId(machineOrder.getId());
orderSign.setCreateTime(orderSignData.getCreateTime());
orderSign.setCurrentStep(orderSignData.getCurrentStep());
orderSign.setUpdateTime(orderSignData.getUpdateTime());
orderSignService.save(orderSign);
// 改单记录(插入或者修改)
OrderChangeRecord changeRecord = orderItem.getOrderChangeRecord();
if (changeRecord.getId() == null) {
changeRecord.setChangeTime(new Date());
orderChangeRecordService.save(changeRecord);
} else {
changeRecord.setChangeTime(new Date());
orderChangeRecordService.update(changeRecord);
}
}
}
for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
MachineOrder machineOrder = orderItem.getMachineOrder();
/**
* 一个合同下,多个订单,多个改单
* 前面已经被改好的改单,状态为 ORDER_CHANGED, 改好后的订单 状态为 ORDER_CHANGE_FINISHED
* 改单刚刚开始时(还在改单中),状态为 ORDER_CHANGE_ING, 由前端传过来,
* 这种情况表示正在改单,要把状态设置为 ORDER_CHANGED,其他的照旧处理
* 之所以分 ORDER_CHANGE_ING、ORDER_CHANGED,是因为为了修复 多个订单都改单的情况下,对应的机器数量会处理不对
* 一个订单改单-不改机器数量:OK
* 一个订单改单-新增机器数量:OK
* 一个订单改单-减少机器数量:OK
*
* 2个订单都改单-不改机器数量:OK
* 2个订单都改单-新增机器数量:ok
* 2个订单都改单-减少机器数量:OK
*/
if (machineOrder.getStatus().equals(Constant.ORDER_CHANGE_ING)) {
// 更新了被改的需求单为“改单”,持久化至数据库
machineOrder.setUpdateTime(new Date());
machineOrder.setStatus(Constant.ORDER_CHANGED);
machineOrderService.update(machineOrder);
// 获取被改单对应机器,设置改单状态(machine)
Condition tempCondition = new Condition(Machine.class);
tempCondition.createCriteria().andCondition("order_id = ", machineOrder.getId());
// /被改订单的
List<Machine> machineList = machineService.findByCondition(tempCondition);
// 寻找对应新生成的需求单,比较机器数
MachineOrder newOrder = null;
for (MachineOrderWrapper wrapper : machineOrderWrapperList) {
if (wrapper.getMachineOrder().getOriginalOrderId().equals(machineOrder.getId())) {
newOrder = wrapper.getMachineOrder();
break;
}
}
if (newOrder != null) {
// 改单后,机器数量不变或者变少了,需要把这部分机器设置为取消(无论是否已生产)
if (newOrder.getMachineNum() <= machineList.size()) {
logger.info("改单后,机器数量不变或者变少了, 新订单的机器数: " + newOrder.getMachineNum());
// step1 按新订单的机器数量,把 被改订单的机器 挂到新生成的订单
for (int m = 0; m < newOrder.getMachineNum(); m++) {
Machine machine = machineList.get(m);
// /初始化、取消状态,直接将机器的上的需求单号直接绑定到新需求单。 其他状态的机器则改为 改单
logger.info("新生成的订单号" + newOrder.getOrderNum() + "的 【实际的】 机器编号: " + machine.getNameplate() + ",状态: " + machine.getStatus());
if (machine.getStatus().equals(Constant.MACHINE_INITIAL) || machine.getStatus().equals(Constant.MACHINE_CANCELED)) {
} else {
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
// /有改单状态的机器,通知全部安装组长
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(newOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
msg.setType(ServerToClientMsg.MsgType.ORDER_CHANGE);
mqttMessageHelper.sendToClient(Constant.S2C_MACHINE_STATUS_CHANGE, JSON.toJSONString(msg));
}
machine.setOrderId(newOrder.getId());
machine.setUpdateTime(new Date());
machineService.update(machine);
}
// //step2把被改订单里剩下的机器设置为取消
/**
* 因为在改单时不确定哪些机子在生产了,所以管理员根据需要可以在"生产管理"页面,根据实际情况调整机器铭牌号。
*/
tempCondition.createCriteria().andCondition("order_id = ", machineOrder.getId());
List<Machine> machineToBeCancelledList = machineService.findByCondition(tempCondition);
for (Machine machine : machineToBeCancelledList) {
// 如果机器数量不变,这里为0
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
machine.setUpdateTime(new Date());
logger.info("把剩下的机器设置为取消 " + machine.getNameplate());
machineService.update(machine);
}
} else {
/**
* 改单后,机器数量增加了,需要新增机器 ,原先:多出部分机器在审核完成以后自动添加
* --> 2020-0409:有联系单后不再需要审核订单了,所以需要在此生成机器。
*/
logger.info("改单前,原订单机器数量: " + machineList.size());
logger.info("改单后,机器数量增加到了: " + newOrder.getMachineNum());
// //step1 把 被改订单的机器 全部之间挂到新生成的订单,即旧订单就没机器了。
for (int n = 0; n < machineList.size(); n++) {
Machine machine = machineList.get(n);
// /初始化、取消状态,直接将机器的上的需求单号直接绑定到新需求单。 其他状态的机器则改为 改单 (为啥这样?全部改成改单不行吗)
logger.info("新生成的订单号" + newOrder.getOrderNum() + "的 【实际的】 机器编号: " + machine.getNameplate() + ",状态: " + machine.getStatus());
if (machine.getStatus().equals(Constant.MACHINE_INITIAL) || machine.getStatus().equals(Constant.MACHINE_CANCELED)) {
} else {
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
// /有改单状态的机器,通知全部安装组长
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(newOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
msg.setType(ServerToClientMsg.MsgType.ORDER_CHANGE);
mqttMessageHelper.sendToClient(Constant.S2C_MACHINE_STATUS_CHANGE, JSON.toJSONString(msg));
}
machine.setOrderId(newOrder.getId());
machine.setUpdateTime(new Date());
machineService.update(machine);
}
// //step2 再补足 新增的机器
int haveToCreate = newOrder.getMachineNum() - machineList.size();
logger.info("订单" + newOrder.getOrderNum() + ",需要新增机器台数:" + haveToCreate);
for (int c = 0; c < haveToCreate; c++) {
Machine machine = new Machine();
machine.setMachineStrId(Utils.createMachineBasicId() + c);
machine.setOrderId(newOrder.getId());
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_INITIAL)));
machine.setMachineType(newOrder.getMachineType());
machine.setCreateTime(new Date());
if (newOrder.getAllUrgent() == null || !newOrder.getAllUrgent()) {
machine.setIsUrgent(false);
} else {
machine.setIsUrgent(true);
}
machineService.save(machine);
logger.info("have created machine's id: " + machine.getId());
}
}
/* 20180323精简了算法,对于被改的需求单,除了初始化和取消状态的机器保持状态不变,其他机器都设置为该到为状态
if (newOrder.getMachineNum() >= machineOrder.getMachineNum()) {
for (Machine machine : machineList) {
///初始化状态,直接将机器的上的需求单号直接绑定到新需求单
if (machine.getStatus().equals(Constant.MACHINE_INITIAL)) {
} else {
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
}
machine.setOrderId(newOrder.getId());
machine.setUpdateTime(new Date());
machineService.update(machine);
}
} else {
List<Machine> originalInitialMachine = new ArrayList<>();
List<Machine> originalInitialedMachine = new ArrayList<>();
List<Machine> originalOtherMachine = new ArrayList<>();
for (Machine machine : machineList) {
if (machine.getStatus().equals(Constant.MACHINE_CONFIGURED)
||machine.getStatus().equals(Constant.MACHINE_PLANING)
|| machine.getStatus().equals( Constant.MACHINE_INSTALLING)
|| machine.getStatus().equals(Constant.MACHINE_INSTALLED)
|| machine.getStatus().equals(Constant.MACHINE_SPLITED)) {
///查找已配置、计划中、生产中、被拆单、生产完成的机器
originalInitialedMachine.add(machine);
} else if (machine.getStatus().equals(Constant.MACHINE_INITIAL)) {
///初始化状态,未开始计划
originalInitialMachine.add(machine);
} else {
originalOtherMachine.add(machine);
}
}
int addedNum = 0;
//生产中的机器优先处理
for (int i = 0; i < originalInitialedMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
originalInitialedMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
addedNum++;
} else {
originalInitialedMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
}
originalInitialedMachine.get(i).setOrderId(newOrder.getId());
//更新
machineService.update(originalInitialedMachine.get(i));
}
//未计划的机器其次处理
for (int i = 0; i < originalInitialMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
///TODO:是否可以保持“MACHINE_INITIAL”状态不变,因为此时机器还没有计划,也就是说没有对其设置安装流程
//originalInitialMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
addedNum++;
originalInitialMachine.get(i).setOrderId(newOrder.getId());
machineService.update(originalInitialMachine.get(i));
} else {
//删除
machineService.deleteById(originalInitialMachine.get(i).getId());
}
}
//目前只有删除状态的机器(MACHINE_CANCELED)
for (int i = 0; i < originalOtherMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
originalOtherMachine.get(i).setOrderId(newOrder.getId());
machineService.update(originalInitialMachine.get(i));
addedNum++;
} else {
originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
machineService.update(originalInitialMachine.get(i));
}
///对于删除状态的机器不做处理
// else {
// originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
// machineService.update(originalInitialMachine.get(i));
// }
}
}
*/
} else {
// /在同一个合同中没有找到新的需求单,抛出异常
throw new RuntimeException();
}
}
}
return ResultGenerator.genSuccessResult(newMachineOrderId);
}
use of com.eservice.api.model.contract_sign.ContractSign in project sinsim by WilsonHu.
the class OrderSignController method update.
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(Integer contractId, String orderSign) {
if (orderSign == null || "".equals(orderSign)) {
ResultGenerator.genFailResult("签核信息为空!");
}
if (contractId == null || contractId <= 0) {
ResultGenerator.genFailResult("合同ID不存在或者无效!");
}
OrderSign orderSignObj = JSONObject.parseObject(orderSign, OrderSign.class);
if (orderSignObj == null) {
ResultGenerator.genFailResult("签核信息JSON解析失败!");
} else {
// 更新需求单签核记录
orderSignObj.setUpdateTime(new Date());
// 更新需求单状态
List<SignContentItem> orderSignContentList = JSON.parseArray(orderSignObj.getSignContent(), SignContentItem.class);
boolean haveReject = false;
boolean needMakeUpOrderSignForForeignDirector = false;
String currentStep = "";
MachineOrder machineOrder = machineOrderService.findById(orderSignObj.getOrderId());
User machineOrderCreator = userService.findById(machineOrder.getCreateUserId());
for (SignContentItem item : orderSignContentList) {
// 如果签核内容中有“拒绝”状态的签核信息,需要将该
if (item.getResult().equals(Constant.SIGN_REJECT)) {
haveReject = true;
}
if (item.getResult() == Constant.SIGN_INITIAL) {
currentStep = roleService.findById(item.getRoleId()).getRoleName();
break;
}
/**
* 订单审核完成时,创建设计单 2020-1207改了:
* 如果是技术部经理签核且通过,则要生成对应的设计单
* 并且没有生成过联系单
*/
if (item.getRoleId() == Constant.ROLE_ID_TECH_MANAGER && item.getResult().equals(Constant.SIGN_APPROVE)) {
logger.info("技术部经理签核,且通过");
// 查找订单对应的设计单
List<DesignDepInfoDetail> designDepInfoDetailList = designDepInfoService.selectDesignDepInfo(machineOrder.getOrderNum(), null, null, // 审核中
Integer.valueOf(Constant.ORDER_CHECKING), null, null, null, null, null, null);
if (designDepInfoDetailList == null || designDepInfoDetailList.size() == 0) {
commonService.createDesignDepInfo(machineOrder);
}
}
/**
* 技术部签核,更新相关内容:
* 1. 机架长度 来自于技术部经理的签核内容,从“长度”字符开始截取。
*/
if (item.getRoleId() == Constant.ROLE_ID_TECH_MANAGER) {
String commentOfTechManager = item.getComment();
int start = 0;
start = commentOfTechManager.indexOf("机架长度");
if (start == -1) {
start = commentOfTechManager.indexOf("【长度】");
}
if (start == -1) {
start = commentOfTechManager.indexOf("[长度]");
}
if (start == -1) {
start = commentOfTechManager.indexOf("长度");
}
if (start != -1) {
machineOrder.setMachineFrameLength(commentOfTechManager.substring(start));
machineOrderService.update(machineOrder);
logger.info("更新了机架长度为: " + commentOfTechManager.substring(start));
}
}
/**
* 成本核算员签核,更新相关内容:
* 1. 毛利率
*/
if (item.getRoleId() == Constant.ROLE_ID_COST_ACCOUNTANT) {
String grossProfitString = "";
int start = 0;
start = item.getComment().indexOf("【毛利率】");
if (start == -1) {
start = item.getComment().indexOf("[毛利率]");
}
if (start == -1) {
start = item.getComment().indexOf("毛利率");
}
if (start != -1) {
grossProfitString = item.getComment().substring(start);
machineOrder.setGrossProfit(grossProfitString);
machineOrderService.update(machineOrder);
logger.info("更新了毛利率为: " + grossProfitString);
}
}
/**
* 外贸部特殊情况,【外贸部销售经理】审核之后,再由【外贸部总监】审核
* 非外贸部,不需要经过【外贸部总监】审核
*/
if (orderSignObj.getCurrentStep().equals(Constant.SING_STEP_SALES_MANAGER) && item.getRoleId() == Constant.ROLE_ID_SALES_MANAGER && item.getResult().equals(Constant.SIGN_APPROVE)) {
User userSalesManager = userService.selectByAccount(item.getUser());
if (userSalesManager.getMarketGroupName().equals("外贸一部") || userSalesManager.getMarketGroupName().equals("外贸二部")) {
logger.info("外贸部经理签核,且通过,需要【外贸部总监】审核");
} else {
/**
* 内贸部的订单不需要外贸总监审核
* 外贸总监已经在流程中,把数据补充填上,流程往后走
*/
needMakeUpOrderSignForForeignDirector = true;
}
}
}
// 都已经签核
if (!haveReject) {
if (currentStep.equals("")) {
currentStep = Constant.SIGN_FINISHED;
}
orderSignObj.setCurrentStep(currentStep);
orderSignService.update(orderSignObj);
if (needMakeUpOrderSignForForeignDirector) {
makeUpSignContent(orderSignObj);
}
}
/**
* 推送公众号消息给轮到的人(通过售后系统)
*/
Contract contract = contractService.findById(contractId);
String msgInfo = null;
if (haveReject) {
machineOrder.setStatus(Constant.ORDER_REJECTED);
// /需求单相关,当前需求单审核变为初始化“SIGN_INITIAL”
for (SignContentItem item : orderSignContentList) {
item.setResult(Constant.SIGN_INITIAL);
}
orderSignObj.setSignContent(JSONObject.toJSONString(orderSignContentList));
orderSignService.update(orderSignObj);
// 如果有订单驳回,则设置合同为initial状态
contract.setStatus(Constant.CONTRACT_INITIAL);
msgInfo = Constant.STR_MSG_PUSH_SIGN_REFUESED;
} else {
if (machineOrder.getStatus().equals(Constant.ORDER_INITIAL)) {
machineOrder.setStatus(Constant.ORDER_CHECKING);
}
// 需求单签核完成
if (currentStep.equals(Constant.SIGN_FINISHED)) {
machineOrder.setStatus(Constant.ORDER_CHECKING_FINISHED);
commonService.createMachineByOrderId(machineOrder);
msgInfo = Constant.STR_MSG_PUSH_SIGN_DONE;
} else {
msgInfo = Constant.STR_MSG_PUSH_IS_TURN_TO_SIGN;
}
}
machineOrderService.update(machineOrder);
commonService.syncMachineOrderStatusInDesignDepInfo(machineOrder);
// 推送消息
commonService.pushMachineOrderMsgToAftersale(orderSignObj, contract, machineOrder, haveReject, msgInfo);
// 更新合同签核记录
String step = commonService.getCurrentSignStep(contractId);
ContractSign contractSign = contractSignService.detailByContractId(String.valueOf(contractId));
if (step == null || contractSign == null) {
throw new RuntimeException();
} else {
if (step.equals(Constant.SIGN_FINISHED)) {
// 表示签核已经完成,合同设置“CONTRACT_CHECKING_FINISHED”
contract.setStatus(Constant.CONTRACT_CHECKING_FINISHED);
// //需求单也需要设置为签核完成状态“ORDER_CHECKING_FINISHED”
// Condition tempCondition = new Condition(ContractSign.class);
// tempCondition.createCriteria().andCondition("contract_id = ", contractId);
// List<MachineOrder> machineOrderList = machineOrderService.findByCondition(tempCondition);
// for (MachineOrder item : machineOrderList) {
// if (item.getStatus().equals(Constant.ORDER_CHECKING)) {
// item.setStatus(Constant.ORDER_CHECKING_FINISHED);
// }
// machineOrderService.update(item);
// }
// 根据合同中的需求单进行机器添加, 在需求单签核、合同签核都加上是因为最后一步审核可能是需求单,也可能是合同
// commonService.createMachineByContractId(contractId);
}
// else {
// if (haveReject) {
// contract.setStatus(Constant.CONTRACT_REJECTED);
// } else if (contract.getStatus().equals(Constant.CONTRACT_REJECTED)) {
// contract.setStatus(Constant.CONTRACT_CHECKING);
// }
// }
contract.setUpdateTime(new Date());
contractService.update(contract);
}
// contractSign.setCurrentStep(step);
// contractSignService.update(contractSign);
}
return ResultGenerator.genSuccessResult();
}
Aggregations