127 lines
4.0 KiB
Java
127 lines
4.0 KiB
Java
|
package nccloud.web.pp.supplierprice.action;
|
|||
|
|
|||
|
import java.util.ArrayList;
|
|||
|
import java.util.List;
|
|||
|
|
|||
|
import com.alibaba.fastjson.JSONArray;
|
|||
|
import com.alibaba.fastjson.JSONObject;
|
|||
|
|
|||
|
import nc.bs.framework.common.InvocationInfoProxy;
|
|||
|
import nc.itf.pp.supplierprice.ISupplierPriceService;
|
|||
|
import nc.vo.bd.meta.BatchOperateVO;
|
|||
|
import nc.vo.pp.supplierprice.entity.SupplierPriceVO;
|
|||
|
import nc.vo.pub.BusinessException;
|
|||
|
import nc.vo.pub.VOStatus;
|
|||
|
import nc.vo.pub.lang.UFDateTime;
|
|||
|
import nc.vo.pubapp.AppContext;
|
|||
|
import nc.vo.scmpub.util.StringUtil;
|
|||
|
import nccloud.framework.core.exception.ExceptionUtils;
|
|||
|
import nccloud.framework.service.ServiceLocator;
|
|||
|
import nccloud.framework.web.action.itf.ICommonAction;
|
|||
|
import nccloud.framework.web.container.IRequest;
|
|||
|
import nccloud.framework.web.ui.pattern.grid.Grid;
|
|||
|
import nccloud.framework.web.ui.pattern.grid.GridOperator;
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD>Ӧ<EFBFBD>̼<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @author ligangt
|
|||
|
* @date 2018-4-17
|
|||
|
* @version v1.0
|
|||
|
*/
|
|||
|
public class SaveAction implements ICommonAction {
|
|||
|
|
|||
|
@Override
|
|||
|
public Object doAction(IRequest request) {
|
|||
|
try {
|
|||
|
// ת<><D7AA>ǰ̨json
|
|||
|
GridOperator operator = new GridOperator();
|
|||
|
SupplierPriceVO[] vos = operator.toVos(request);
|
|||
|
|
|||
|
// <20><><EFBFBD><EFBFBD>ǰ̨<C7B0><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD>飬<EFBFBD><E9A3AC><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ʱУ<CAB1><D0A3>
|
|||
|
String updateKeysjson = operator.getOriginGrid().getUserjson();
|
|||
|
// <20><>ȡ<EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Դ<EFBFBD>Ĺ<EFBFBD>Ӧ<EFBFBD>̼<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>ʧЧ<CAA7><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶΣ<D6B6><CEA3><EFBFBD>ӦΪ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ˵<D6B5><CBB5><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
int updateKeysNum = StringUtil.isSEmptyOrNull(updateKeysjson) ? 0
|
|||
|
: ((JSONArray) JSONObject.parse(updateKeysjson)).size();
|
|||
|
|
|||
|
List<SupplierPriceVO> addList = new ArrayList<SupplierPriceVO>();
|
|||
|
List<SupplierPriceVO> updateList = new ArrayList<SupplierPriceVO>();
|
|||
|
List<SupplierPriceVO> deleteList = new ArrayList<SupplierPriceVO>();
|
|||
|
List<SupplierPriceVO> unchangedList = new ArrayList<SupplierPriceVO>();
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//zhangxinah<61><68><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
String cuserid = InvocationInfoProxy.getInstance().getUserId();
|
|||
|
List<String> orderKey = new ArrayList<>();
|
|||
|
if (vos != null) {
|
|||
|
for (SupplierPriceVO vo : vos) {
|
|||
|
if (VOStatus.NEW == vo.getStatus()) {
|
|||
|
//<2F>Ƶ<EFBFBD><C6B5><EFBFBD>
|
|||
|
vo.setAttributeValue("vbdef17", cuserid);
|
|||
|
//<2F>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
vo.setAttributeValue("vbdef18", new UFDateTime());
|
|||
|
addList.add(vo);
|
|||
|
} else if (VOStatus.UPDATED == vo.getStatus()) {
|
|||
|
//<2F><EFBFBD><DEB8><EFBFBD>
|
|||
|
vo.setAttributeValue("vbdef19", cuserid);
|
|||
|
//<2F><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
vo.setAttributeValue("vbdef20", new UFDateTime());
|
|||
|
orderKey.add(vo.getPk_supplierprice());
|
|||
|
updateList.add(vo);
|
|||
|
} else if (VOStatus.DELETED == vo.getStatus()) {
|
|||
|
deleteList.add(vo);
|
|||
|
} else {
|
|||
|
unchangedList.add(vo);
|
|||
|
orderKey.add(vo.getPk_supplierprice());
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
// <20><><EFBFBD>ýӿڱ<D3BF><DAB1><EFBFBD>
|
|||
|
ISupplierPriceService service = ServiceLocator.find(ISupplierPriceService.class);
|
|||
|
BatchOperateVO batchVO = new BatchOperateVO();
|
|||
|
batchVO.setAddObjs(addList.toArray());
|
|||
|
batchVO.setUpdObjs(updateList.toArray());
|
|||
|
batchVO.setDelObjs(deleteList.toArray());
|
|||
|
BatchOperateVO resvo = service.batchSave(batchVO, updateKeysNum);
|
|||
|
// ת<><D7AA><EFBFBD><EFBFBD>ǰ̨dto
|
|||
|
List<SupplierPriceVO> voList = new ArrayList<SupplierPriceVO>();
|
|||
|
|
|||
|
for (String key : orderKey) {
|
|||
|
if (resvo.getUpdObjs() != null) {
|
|||
|
for (Object obj : resvo.getUpdObjs()) {
|
|||
|
SupplierPriceVO vo = (SupplierPriceVO) obj;
|
|||
|
if (key.equals(vo.getPk_supplierprice())) {
|
|||
|
voList.add(vo);
|
|||
|
}
|
|||
|
}
|
|||
|
for (SupplierPriceVO vo : unchangedList) {
|
|||
|
if (key.equals(vo.getPk_supplierprice())) {
|
|||
|
voList.add(vo);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (resvo.getAddObjs() != null) {
|
|||
|
Object[] addObjs = resvo.getAddObjs();
|
|||
|
for (Object obj : addObjs) {
|
|||
|
voList.add((SupplierPriceVO) obj);
|
|||
|
}
|
|||
|
// voList.addAll(Arrays.asList(resvo.getAddObjs()));
|
|||
|
}
|
|||
|
|
|||
|
vos = voList.toArray(new SupplierPriceVO[voList.size()]);
|
|||
|
if (vos != null && vos.length > 0) {
|
|||
|
Grid grid = operator.toGrid(vos);
|
|||
|
SupplierPricePrecisionProcessor util = new SupplierPricePrecisionProcessor();
|
|||
|
util.process(grid);
|
|||
|
return grid;
|
|||
|
}
|
|||
|
|
|||
|
} catch (BusinessException e) {
|
|||
|
ExceptionUtils.wrapException(e);
|
|||
|
}
|
|||
|
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
}
|