继续优化单据的逻辑

This commit is contained in:
季圣华
2020-10-13 23:13:48 +08:00
parent 4428352b35
commit df4fa41b23
7 changed files with 214 additions and 259 deletions

View File

@@ -1045,8 +1045,6 @@
//自动计算事件 //自动计算事件
autoReckon: function () { autoReckon: function () {
var self = this; var self = this;
//延时绑定事件
setTimeout(function(){
var inputDom = $("#depotHeadFM .panel.datagrid .datagrid-view2 .datagrid-body"); var inputDom = $("#depotHeadFM .panel.datagrid .datagrid-view2 .datagrid-body");
var appendDom = $("#depotHeadDlg #append"); var appendDom = $("#depotHeadDlg #append");
autoJumpNextInput(inputDom, appendDom); //敲回车键自动跳转到下一个文本框 autoJumpNextInput(inputDom, appendDom); //敲回车键自动跳转到下一个文本框
@@ -1183,8 +1181,11 @@
rowDom.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额 rowDom.find("[field='TaxMoney']").find(input).val((UnitPrice*OperNumber*(taxRate/100)).toFixed(2)); //税额
self.statisticsFun(body,UnitPrice,OperNumber,footer,taxRate); self.statisticsFun(body,UnitPrice,OperNumber,footer,taxRate);
}); });
setTimeout(function(){
var body =$("#depotHeadFM .datagrid-view2 .datagrid-body");
var input = "input[type=text]";
//默认税率为0 //默认税率为0
var taxRateDom = body.find("[field='TaxRate']").find(input); var taxRateDom = body.find(".datagrid-row").eq(editIndex).find("[field='TaxRate']").find(input);
if(taxRateDom.val() == "") { if(taxRateDom.val() == "") {
taxRateDom.val(0); taxRateDom.val(0);
} }
@@ -1198,7 +1199,7 @@
if(listSubType == "组装单" || listSubType == "拆卸单"){ if(listSubType == "组装单" || listSubType == "拆卸单"){
mType.find(input).val(mTypeValue).prop("readonly","readonly"); mType.find(input).val(mTypeValue).prop("readonly","readonly");
} }
},500); },100);
}, },
//新增明细 //新增明细
append: function () { append: function () {
@@ -1344,7 +1345,7 @@
sessionStorage.removeItem("rowInfo"); sessionStorage.removeItem("rowInfo");
} }
this.endAllEdit(); this.endAllEdit();
var inserted = $("#materialData").datagrid('getRows'); var rows = $("#materialData").datagrid('getRows');
$.ajax({ $.ajax({
type:"post", type:"post",
url: url, url: url,
@@ -1353,7 +1354,7 @@
async : false, async : false,
data: JSON.stringify({ data: JSON.stringify({
info:infoStr, info:infoStr,
inserted: JSON.stringify(inserted) rows: JSON.stringify(rows)
}), }),
success: function (tipInfo){ success: function (tipInfo){
if(tipInfo){ if(tipInfo){
@@ -1383,7 +1384,7 @@
updateDepotHeadAndDetail: function (url,infoStr,preTotalPrice) { updateDepotHeadAndDetail: function (url,infoStr,preTotalPrice) {
var self = this; var self = this;
this.endAllEdit(); this.endAllEdit();
var inserted = $("#materialData").datagrid('getRows'); var rows = $("#materialData").datagrid('getRows');
$.ajax({ $.ajax({
type:"post", type:"post",
url: url, url: url,
@@ -1393,7 +1394,7 @@
data: JSON.stringify({ data: JSON.stringify({
id:url.substring(url.lastIndexOf("?id=")+4,url.length), id:url.substring(url.lastIndexOf("?id=")+4,url.length),
info:infoStr, info:infoStr,
inserted: JSON.stringify(inserted), rows: JSON.stringify(rows),
preTotalPrice:preTotalPrice preTotalPrice:preTotalPrice
}), }),
success: function (tipInfo){ success: function (tipInfo){

View File

@@ -341,7 +341,7 @@ public class DepotHeadController {
public Object addDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{ public Object addDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess(); JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo(); String beanJson = body.getInfo();
String inserted = body.getInserted(); String rows = body.getRows();
Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString()); Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString());
Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString());
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null); Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
@@ -349,7 +349,7 @@ public class DepotHeadController {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE, throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG); ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
} else { } else {
depotHeadService.addDepotHeadAndDetail(beanJson,inserted,tenantId, request); depotHeadService.addDepotHeadAndDetail(beanJson,rows,tenantId, request);
} }
return result; return result;
} }
@@ -367,9 +367,9 @@ public class DepotHeadController {
JSONObject result = ExceptionConstants.standardSuccess(); JSONObject result = ExceptionConstants.standardSuccess();
Long id = body.getId(); Long id = body.getId();
String beanJson = body.getInfo(); String beanJson = body.getInfo();
String inserted = body.getInserted(); String rows = body.getRows();
BigDecimal preTotalPrice = body.getPreTotalPrice(); BigDecimal preTotalPrice = body.getPreTotalPrice();
depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,preTotalPrice,tenantId,request); depotHeadService.updateDepotHeadAndDetail(id,beanJson,rows,preTotalPrice,tenantId,request);
return result; return result;
} }

View File

@@ -8,11 +8,7 @@ public class DepotHeadVo4Body {
private String info; private String info;
private String inserted; private String rows;
private String deleted;
private String updated;
private BigDecimal preTotalPrice; private BigDecimal preTotalPrice;
@@ -32,28 +28,12 @@ public class DepotHeadVo4Body {
this.info = info; this.info = info;
} }
public String getInserted() { public String getRows() {
return inserted; return rows;
} }
public void setInserted(String inserted) { public void setRows(String rows) {
this.inserted = inserted; this.rows = rows;
}
public String getDeleted() {
return deleted;
}
public void setDeleted(String deleted) {
this.deleted = deleted;
}
public String getUpdated() {
return updated;
}
public void setUpdated(String updated) {
this.updated = updated;
} }
public BigDecimal getPreTotalPrice() { public BigDecimal getPreTotalPrice() {

View File

@@ -52,7 +52,7 @@ public interface SerialNumberMapperEx {
* */ * */
int sellSerialNumber(@Param("materialId")Long materialId, @Param("depotHeadId")Long depotHeadId,@Param("count")Integer count, @Param("updateTime") Date updateTime,@Param("updater") Long updater); int sellSerialNumber(@Param("materialId")Long materialId, @Param("depotHeadId")Long depotHeadId,@Param("count")Integer count, @Param("updateTime") Date updateTime,@Param("updater") Long updater);
/** /**
* 赎回update jsh_serial_number set is_Sell='0' where 1=1 and material_Id='materialId' * 赎回update jsh_serial_number set is_Sell='0',depothead_Id=null where 1=1 and material_Id='materialId'
* and depothead_Id='depotheadId' and is_Sell ='0' and delete_Flag !='1' {limit 0count} * and depothead_Id='depotheadId' and is_Sell ='0' and delete_Flag !='1' {limit 0count}
* */ * */
int cancelSerialNumber(@Param("materialId")Long materialId, @Param("depotHeadId")Long depotHeadId, @Param("count")Integer count, @Param("updateTime") Date updateTime,@Param("updater") Long updater); int cancelSerialNumber(@Param("materialId")Long materialId, @Param("depotHeadId")Long depotHeadId, @Param("count")Integer count, @Param("updateTime") Date updateTime,@Param("updater") Long updater);

View File

@@ -469,13 +469,13 @@ public class DepotHeadService {
/** /**
* 新增单据主表及单据子表信息 * 新增单据主表及单据子表信息
* @param beanJson * @param beanJson
* @param inserted * @param rows
* @param tenantId * @param tenantId
* @param request * @param request
* @throws Exception * @throws Exception
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addDepotHeadAndDetail(String beanJson, String inserted, Long tenantId, public void addDepotHeadAndDetail(String beanJson, String rows, Long tenantId,
HttpServletRequest request) throws Exception { HttpServletRequest request) throws Exception {
/**处理单据主表数据*/ /**处理单据主表数据*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
@@ -502,7 +502,7 @@ public class DepotHeadService {
if(list!=null) { if(list!=null) {
Long headId = list.get(0).getId(); Long headId = list.get(0).getId();
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,headId,tenantId, request); depotItemService.saveDetials(rows,headId,tenantId, request);
} }
/**如果关联单据号非空则更新订单的状态为2 */ /**如果关联单据号非空则更新订单的状态为2 */
if(depotHead.getLinkNumber()!=null) { if(depotHead.getLinkNumber()!=null) {
@@ -525,14 +525,14 @@ public class DepotHeadService {
* 更新单据主表及单据子表信息 * 更新单据主表及单据子表信息
* @param id * @param id
* @param beanJson * @param beanJson
* @param inserted * @param rows
* @param preTotalPrice * @param preTotalPrice
* @param tenantId * @param tenantId
* @param request * @param request
* @throws Exception * @throws Exception
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateDepotHeadAndDetail(Long id, String beanJson, String inserted, public void updateDepotHeadAndDetail(Long id, String beanJson, String rows,
BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception { BigDecimal preTotalPrice, Long tenantId,HttpServletRequest request)throws Exception {
/**更新单据主表信息*/ /**更新单据主表信息*/
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
@@ -550,7 +550,7 @@ public class DepotHeadService {
} }
} }
/**入库和出库处理单据子表信息*/ /**入库和出库处理单据子表信息*/
depotItemService.saveDetials(inserted,depotHead.getId(),tenantId,request); depotItemService.saveDetials(rows,depotHead.getId(),tenantId,request);
logService.insertLog("单据", logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHead.getNumber()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());

View File

@@ -296,74 +296,46 @@ public class DepotItemService {
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, Long headerId, Long tenantId, HttpServletRequest request) throws Exception{ public void saveDetials(String rows, Long headerId, Long tenantId, HttpServletRequest request) throws Exception{
//查询单据主表信息 //查询单据主表信息
DepotHead depotHead=null; DepotHead depotHead=null;
try{ try{
depotHead =depotHeadMapper.selectByPrimaryKey(headerId); depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
}catch(Exception e){
JshException.readFail(logger, e);
}
//获得当前操作人 //获得当前操作人
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
//转为json //首先回收序列号,如果是调拨,不用处理序列号
JSONArray insertedJson = JSONArray.parseArray(inserted); if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())){
List<DepotItem> depotItemList = getListByHeaderId(headerId);
for(DepotItem depotItem : depotItemList){
Material material= materialService.getMaterial(depotItem.getMaterialId());
if(material==null){
continue;
}
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableSerialNumber())){
serialNumberService.cancelSerialNumber(depotItem.getMaterialId(),depotItem.getHeaderId(),
(depotItem.getBasicNumber()==null?0:depotItem.getBasicNumber()).intValue(), userInfo);
}
}
}
//删除单据的明细 //删除单据的明细
deleteDepotItemHeadId(headerId); deleteDepotItemHeadId(headerId);
JSONArray rowArr = JSONArray.parseArray(rows);
// if (null != deletedJson) { if (null != rowArr) {
// StringBuffer bf=new StringBuffer(); for (int i = 0; i < rowArr.size(); i++) {
// for (int i = 0; i < deletedJson.size(); i++) {
// //首先回收序列号,如果是调拨,不用处理序列号
// JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
// if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
// &&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubType())){
// DepotItem depotItem = getDepotItem(tempDeletedJson.getLong("Id"));
// if(depotItem==null){
// continue;
// }
// /**
// * 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
// * */
// Material material= materialService.getMaterial(depotItem.getMaterialId());
// if(material==null){
// continue;
// }
// if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableSerialNumber())){
// serialNumberService.cancelSerialNumber(depotItem.getMaterialId(),depotItem.getHeaderId(),(depotItem.getBasicNumber()==null?0:depotItem.getBasicNumber()).intValue(),
// userInfo);
// }
// }
// bf.append(tempDeletedJson.getLong("Id"));
// if(i<(deletedJson.size()-1)){
// bf.append(",");
// }
// }
// this.batchDeleteDepotItemByIds(bf.toString());
// //更新当前库存
// for (int i = 0; i < deletedJson.size(); i++) {
// JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
// DepotItem depotItem = getDepotItem(tempDeletedJson.getLong("Id"));
// updateCurrentStock(depotItem,tenantId);
// }
// }
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
DepotItem depotItem = new DepotItem(); DepotItem depotItem = new DepotItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i)); JSONObject rowObj = JSONObject.parseObject(rowArr.getString(i));
depotItem.setHeaderId(headerId); depotItem.setHeaderId(headerId);
Long materialExtendId = tempInsertedJson.getLong("MaterialExtendId"); Long materialExtendId = rowObj.getLong("MaterialExtendId");
Long materialId = materialExtendService.getMaterialExtend(materialExtendId).getMaterialId(); Long materialId = materialExtendService.getMaterialExtend(materialExtendId).getMaterialId();
depotItem.setMaterialId(materialId); depotItem.setMaterialId(materialId);
depotItem.setMaterialExtendId(tempInsertedJson.getLong("MaterialExtendId")); depotItem.setMaterialExtendId(rowObj.getLong("MaterialExtendId"));
depotItem.setMaterialUnit(tempInsertedJson.getString("Unit")); depotItem.setMaterialUnit(rowObj.getString("Unit"));
if (StringUtil.isExist(tempInsertedJson.get("OperNumber"))) { if (StringUtil.isExist(rowObj.get("OperNumber"))) {
depotItem.setOperNumber(tempInsertedJson.getBigDecimal("OperNumber")); depotItem.setOperNumber(rowObj.getBigDecimal("OperNumber"));
try { try {
String Unit = tempInsertedJson.get("Unit").toString(); String Unit = rowObj.get("Unit").toString();
BigDecimal oNumber = tempInsertedJson.getBigDecimal("OperNumber"); BigDecimal oNumber = rowObj.getBigDecimal("OperNumber");
//以下进行单位换算 //以下进行单位换算
String unitName = materialService.findUnitName(materialId); //查询计量单位名称 String unitName = materialService.findUnitName(materialId); //查询计量单位名称
if (!StringUtil.isEmpty(unitName)) { if (!StringUtil.isEmpty(unitName)) {
@@ -384,36 +356,36 @@ public class DepotItemService {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e); logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
} }
} }
if (StringUtil.isExist(tempInsertedJson.get("UnitPrice"))) { if (StringUtil.isExist(rowObj.get("UnitPrice"))) {
depotItem.setUnitPrice(tempInsertedJson.getBigDecimal("UnitPrice")); depotItem.setUnitPrice(rowObj.getBigDecimal("UnitPrice"));
} }
if (StringUtil.isExist(tempInsertedJson.get("TaxUnitPrice"))) { if (StringUtil.isExist(rowObj.get("TaxUnitPrice"))) {
depotItem.setTaxUnitPrice(tempInsertedJson.getBigDecimal("TaxUnitPrice")); depotItem.setTaxUnitPrice(rowObj.getBigDecimal("TaxUnitPrice"));
} }
if (StringUtil.isExist(tempInsertedJson.get("AllPrice"))) { if (StringUtil.isExist(rowObj.get("AllPrice"))) {
depotItem.setAllPrice(tempInsertedJson.getBigDecimal("AllPrice")); depotItem.setAllPrice(rowObj.getBigDecimal("AllPrice"));
} }
depotItem.setRemark(tempInsertedJson.getString("Remark")); depotItem.setRemark(rowObj.getString("Remark"));
if (tempInsertedJson.get("DepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("DepotId").toString())) { if (rowObj.get("DepotId") != null && !StringUtil.isEmpty(rowObj.get("DepotId").toString())) {
depotItem.setDepotId(tempInsertedJson.getLong("DepotId")); depotItem.setDepotId(rowObj.getLong("DepotId"));
} }
if (tempInsertedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())) { if (rowObj.get("AnotherDepotId") != null && !StringUtil.isEmpty(rowObj.get("AnotherDepotId").toString())) {
depotItem.setAnotherDepotId(tempInsertedJson.getLong("AnotherDepotId")); depotItem.setAnotherDepotId(rowObj.getLong("AnotherDepotId"));
} }
if (StringUtil.isExist(tempInsertedJson.get("TaxRate"))) { if (StringUtil.isExist(rowObj.get("TaxRate"))) {
depotItem.setTaxRate(tempInsertedJson.getBigDecimal("TaxRate")); depotItem.setTaxRate(rowObj.getBigDecimal("TaxRate"));
} }
if (StringUtil.isExist(tempInsertedJson.get("TaxMoney"))) { if (StringUtil.isExist(rowObj.get("TaxMoney"))) {
depotItem.setTaxMoney(tempInsertedJson.getBigDecimal("TaxMoney")); depotItem.setTaxMoney(rowObj.getBigDecimal("TaxMoney"));
} }
if (StringUtil.isExist(tempInsertedJson.get("TaxLastMoney"))) { if (StringUtil.isExist(rowObj.get("TaxLastMoney"))) {
depotItem.setTaxLastMoney(tempInsertedJson.getBigDecimal("TaxLastMoney")); depotItem.setTaxLastMoney(rowObj.getBigDecimal("TaxLastMoney"));
} }
if (tempInsertedJson.get("MType") != null) { if (rowObj.get("MType") != null) {
depotItem.setMaterialType(tempInsertedJson.getString("MType")); depotItem.setMaterialType(rowObj.getString("MType"));
} }
if (tempInsertedJson.get("Remark") != null) { if (rowObj.get("Remark") != null) {
depotItem.setRemark(tempInsertedJson.getString("Remark")); depotItem.setRemark(rowObj.getString("Remark"));
} }
//出库时判断库存是否充足 //出库时判断库存是否充足
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){ if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())){
@@ -444,7 +416,9 @@ public class DepotItemService {
updateCurrentStock(depotItem,tenantId); updateCurrentStock(depotItem,tenantId);
} }
} }
return null; }catch(Exception e){
JshException.writeFail(logger, e);
}
} }
/** /**
* 查询计量单位信息 * 查询计量单位信息

View File

@@ -180,7 +180,7 @@
<update id="cancelSerialNumber"> <update id="cancelSerialNumber">
update jsh_serial_number update jsh_serial_number
<set> <set>
is_sell = '0', is_sell = '0', depot_head_id=null,
<if test="updateTime !=null "> <if test="updateTime !=null ">
update_time = #{updateTime}, update_time = #{updateTime},
</if> </if>