Browse Source

精度修改

master
shenzhouyu 10 months ago
parent
commit
8b6e489712
  1. 15
      src/main/java/com/gaotao/modules/notify/controller/IssureNotifyController.java
  2. 1
      src/main/java/com/gaotao/modules/notify/mapper/IssureNotifyMapper.java
  3. 5
      src/main/java/com/gaotao/modules/notify/service/IssureNotifyService.java
  4. 57
      src/main/java/com/gaotao/modules/notify/service/impl/IssureNotifyServiceImpl.java
  5. 26
      src/main/java/com/gaotao/modules/trans/service/impl/ValidateInventoryPartInStockServiceImpl.java
  6. 8
      src/main/resources/mapper/notify/IssureNotifyMapper.xml

15
src/main/java/com/gaotao/modules/notify/controller/IssureNotifyController.java

@ -371,4 +371,19 @@ public class IssureNotifyController {
return R.error("操作失败");
}
/**-----------------------------------------无订单时的接口---------------------------------------------------------*/
@PostMapping(value="/getUserNoOrderNotifyNo")
@ResponseBody
public R getUserNoOrderNotifyNo(@RequestBody SOIssueNotifyHeaderData data) {
SOIssueNotifyHeaderData row = issureNotifyService.getUserNoOrderNotifyNo(data);
return R.ok().put("row", row);
}
@PostMapping(value="/createNoOrderNotify")
@ResponseBody
public R createNoOrderNotify(@RequestBody SOIssueNotifyHeaderData data) throws ParseException {
issureNotifyService.createNoOrderNotify(data);
return R.ok();
}
}

1
src/main/java/com/gaotao/modules/notify/mapper/IssureNotifyMapper.java

@ -154,4 +154,5 @@ public interface IssureNotifyMapper extends BaseMapper<SOIssueNotifyHeader> {
int batchSaveSOIssueNotifyOrderMaterialList(@Param("childList") List<SOIssueNotifyOrderMaterialList> childList);
SOIssueNotifyHeaderData getUserNoOrderNotifyNo(SOIssueNotifyHeaderData data);
}

5
src/main/java/com/gaotao/modules/notify/service/IssureNotifyService.java

@ -164,4 +164,9 @@ public interface IssureNotifyService {
void cancelIssueNotify(SOIssueNotifyHeaderData data);
String saveNewSoIssueNotify(NewSoIssueNotifyDto data) throws Exception;
/**---------------------------------------------无订单时的接口-------------------------------------------------*/
SOIssueNotifyHeaderData getUserNoOrderNotifyNo(SOIssueNotifyHeaderData data);
void createNoOrderNotify(SOIssueNotifyHeaderData data);
}

57
src/main/java/com/gaotao/modules/notify/service/impl/IssureNotifyServiceImpl.java

@ -724,7 +724,7 @@ public class IssureNotifyServiceImpl implements IssureNotifyService {
parentList.add(parent);
// 2.3 遍历分组内的 dto lineItemNo 生成子对象SOIssueNotifyOrderMaterialList
List<SOIssueNotifyOrderMaterialList> children = buildChildren(data.getNotifyNo(),data.getSite(),groupDtos, nextItem);
List<SOIssueNotifyOrderMaterialList> children = buildChildren(data.getNotifyNo(),data.getSite(),groupDtos, nextItem,parent.getOrderType());
childList.addAll(children);
num++;
@ -779,14 +779,22 @@ public class IssureNotifyServiceImpl implements IssureNotifyService {
parent.setFgPartNo(firstDto.getPartNo());
parent.setNeedDate(firstDto.getNeedDate());
parent.setTransportFlag("N");
parent.setOrderType("shoporder");
if(firstDto.getPartNo() != null){
if(firstDto.getPartNo().startsWith("3") || firstDto.getPartNo().startsWith("7")){
parent.setOrderType("slittingorder");
}else{
parent.setOrderType("shoporder");
}
}else{
parent.setOrderType("shoporder");
}
return parent;
}
/**
* 构建子对象列表SOIssueNotifyOrderMaterialList关联父对象的 itemNo
*/
private static List<SOIssueNotifyOrderMaterialList> buildChildren(String notifyNo,String site,List<ShoporderAndMaterialDto> groupDtos, BigDecimal parentItemNo) {
private static List<SOIssueNotifyOrderMaterialList> buildChildren(String notifyNo,String site,List<ShoporderAndMaterialDto> groupDtos, BigDecimal parentItemNo,String parentType) {
return groupDtos.stream()
.map(dto -> {
SOIssueNotifyOrderMaterialList child = new SOIssueNotifyOrderMaterialList();
@ -802,11 +810,52 @@ public class IssureNotifyServiceImpl implements IssureNotifyService {
child.setQtyToIssueOriginal(dto.getApplyQty());
}
child.setIssueType("BOM物料");
child.setOrderType("shoporder");
if(StringUtils.isNotBlank(parentType)){
child.setOrderType(parentType);
}else{
child.setOrderType("shoporder");
}
return child;
})
// lineItemNo 排序可选确保子项顺序
.sorted(Comparator.comparing(SOIssueNotifyOrderMaterialList::getBOMItemNo))
.collect(Collectors.toList());
}
/**---------------------------------------------无订单时的接口-------------------------------------------------*/
@Override
public SOIssueNotifyHeaderData getUserNoOrderNotifyNo(SOIssueNotifyHeaderData data) {
SOIssueNotifyHeaderData header = issureNotifyMapper.getUserNoOrderNotifyNo(data);
return header;
}
@Override
@Transactional
public void createNoOrderNotify(SOIssueNotifyHeaderData data) {
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
String transType = "NOSI";
// 获取流水号,出错不回滚
TransNoControl transNo = transNoService.getTransNo(data.getSite(),transType,8);
data.setNotifyNo(transNo.getNewTransNo());
data.setNotifyDate(new Date());
data.setUsername(currentUser.getUsername());
data.setEnteredDate(new Date());
data.setReceiver("");
data.setDepartmentId("");
data.setRemark(data.getRemark());
data.setCreditFlag("N");
data.setIssueFlag("N");
data.setIssueResult("");
data.setStatus("UNISSUE");
data.setHaveIssueRecordFlag("N");
data.setCalcFlag("N");
data.setNeedApproveFlag("N");
data.setApprovedFlag("N");
data.setOutWorkOrderFlag(data.getOutWorkOrderFlag());
data.setProjectId("");
data.setOrderType("otherOrder");
data.setPushWcsFlag("未推送");
issureNotifyMapper.insert(data);
}
}

26
src/main/java/com/gaotao/modules/trans/service/impl/ValidateInventoryPartInStockServiceImpl.java

@ -11,10 +11,12 @@ import com.gaotao.modules.trans.entity.TransCommonSubDto;
import com.gaotao.modules.trans.entity.TransDetail;
import com.gaotao.modules.trans.entity.TransDetailSub;
import com.gaotao.modules.trans.service.ValidateInventoryPartInStockService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -76,10 +78,32 @@ public class ValidateInventoryPartInStockServiceImpl implements ValidateInventor
&& vo.getLocationNo().equals(key.get(3))
&& vo.getWaivDevRejNo().equals(key.get(4))
){
if(!"N".equals(vo.getFreezeFlagDb()) || (new BigDecimal(vo.getQtyOnhand()).subtract(new BigDecimal(vo.getQtyReserved())).compareTo(new BigDecimal(totalQty)))< 0){
// 1. 处理 qtyOnhandString类型空值默认0
String onhandStr = vo.getQtyOnhand();
BigDecimal qtyOnhand = StringUtils.isBlank(onhandStr)
? BigDecimal.ZERO
: new BigDecimal(onhandStr); // String转BigDecimal无精度损失
// 2. 处理 qtyReserved假设也是String类型同理空值默认0
String reservedStr = vo.getQtyReserved();
BigDecimal qtyReserved = StringUtils.isBlank(reservedStr)
? BigDecimal.ZERO
: new BigDecimal(reservedStr);
BigDecimal availableQty = qtyOnhand.subtract(qtyReserved);
// 2. 统一设置精度如保留4位小数四舍五入
BigDecimal availableQtyScaled = availableQty.setScale(4, RoundingMode.HALF_UP);
BigDecimal totalQtyScaled = BigDecimal.valueOf(totalQty).setScale(4, RoundingMode.HALF_UP);
// 3. 用统一精度后的值比较
if (!"N".equals(vo.getFreezeFlagDb()) || availableQtyScaled.compareTo(totalQtyScaled) < 0) {
flag = true;
break;
}
/*if(!"N".equals(vo.getFreezeFlagDb()) || (new BigDecimal(vo.getQtyOnhand()).subtract(new BigDecimal(vo.getQtyReserved())).compareTo(new BigDecimal(totalQty)))< 0){
flag = true;
break;
}*/
}
}

8
src/main/resources/mapper/notify/IssureNotifyMapper.xml

@ -412,5 +412,13 @@ record_version,out_work_order_flag,project_id,order_type,auth_rule_id,bu)
(#{item.notifyNo},#{item.site},#{item.itemNo},#{item.bOMItemNo},#{item.componentPartNo},#{item.qtyToIssue,jdbcType=DECIMAL},#{item.qtyToIssueOriginal,jdbcType=DECIMAL},#{item.issueType},rtrim(#{item.remark}),#{item.orderType})
</foreach>
</insert>
<select id="getUserNoOrderNotifyNo" resultType="com.gaotao.modules.notify.entity.SOIssueNotifyHeaderData">
select top 1 a.notify_no,a.site,a.notify_date,a.username,a.entered_date,a.receiver,a.department_id,a.remark,a.credit_flag,a.issue_flag,
a.issue_result,a.plan_issue_date,a.real_issue_date,a.status,a.have_issue_record_flag,a.calc_flag,a.need_approve_flag,a.approved_flag,
a.approver,a.approve_date,a.warehouse_id,a.record_version,a.out_work_order_flag,a.project_id,a.order_type,a.auth_rule_id,a.handler_username,a.handler_display
from SOIssueNotifyHeader a
where a.site=#{site} and a.username=#{username} and a.status='UNISSUE' and a.order_type='otherOrder'
order by a.entered_date desc
</select>
</mapper>
Loading…
Cancel
Save